wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

67 Quiz Q2 y7

Total questions: 67

Worksheet time: 34mins

Name
Class
Date
1.

What is the main purpose of using loops in programming?

a)

To perform tasks only once

b)

To repeat tasks many times

c)

To stop tasks from repeating

d)

To make tasks more complicated

2.

Which type of loop is used in Python for counting iterations?

a)

Forever loop

b)

Counter loop

c)

Conditional loop

d)

Infinite loop

3.

What type of loop is represented by "while" in Python?

a)

Forever loop

b)

Counter loop

c)

Conditional loop

d)

Repeat loop

4.

What does the operator "<" mean in Python?

a)

Greater than

b)

Less than

c)

Equal to

d)

Not equal to

5.

Which operator is used to check if two values are equal in Python?

a)

!=

b)

<

c)

==

d)

>

6.

What is the meaning of the operator ">=" in Python?

a)

Less than

b)

Greater than

c)

Less than or equal to

d)

Greater than or equal to

7.

In Scratch, which operator would you use to add two numbers?

a)

-

b)

*

c)

/

d)

+

8.

What is a key advantage of using loops in programming?

a)

They make the code run slower

b)

They require more code to be written

c)

They reduce the chance of errors

d)

They increase the complexity of the code

9.

When should you use a 'for loop' in programming?

a)

When you want to repeat an action an unknown number of times

b)

When you want to repeat an action a specific number of times

c)

When you want to repeat an action until a condition is met

d)

When you want to repeat an action randomly

10.

What is the purpose of a "for" loop in programming?

a)

To execute a block of code a specific number of times

b)

To execute a block of code only once

c)

To execute a block of code indefinitely

d)

To execute a block of code based on a condition

11.

In a "for" loop, what does the "range" function do?

a)

It creates a list of numbers

b)

It checks a condition

c)

It prints a message

d)

It stops the loop

12.

What is the role of indentation in a "for" loop?

a)

It marks the end of the loop

b)

It indicates the start of the loop

c)

It defines the block of code to be repeated

d)

It is used to comment the code

13.

What is the correct syntax to start a "for" loop in Python?

a)

for i in range(number):

b)

for each i in range(number)

c)

for i range(number):

d)

for i in range number:

14.

What is the output of the following code snippet?

a)

1 2 3 4

b)

4 3 2 1

c)

1 3 2 4

d)

2 3 4 5

15.

What does the 'range' function do in programming?

a)

It generates a sequence of numbers starting from 0.

b)

It sorts a list of numbers.

c)

It reverses a list of numbers.

d)

It multiplies a list of numbers by 2.

16.

What does the function range(5) return in Python?

a)

[0, 1, 2, 3, 4]

b)

[1, 2, 3, 4, 5]

c)

[5, 6, 7, 8, 9]

d)

[0, 1, 2, 3, 4, 5]

17.

If you use range(5, 10) in a loop, what will be the first number printed?

a)

5

b)

6

c)

10

d)

0

18.

What is the output of the following code? for num in range(5): print("Number:", num)

a)

Number: 0, Number: 1, Number: 2, Number: 3, Number: 4

b)

Number: 1, Number: 2, Number: 3, Number: 4, Number: 5

c)

Number: 0, Number: 1, Number: 2, Number: 3

d)

Number: 5, Number: 6, Number: 7, Number: 8, Number: 9

19.

What will be the output of the following code snippet?

a)

This is loop number 2 This is loop number 3 This is loop number 4

b)

This is loop number 3 This is loop number 4 This is loop number 5

c)

This is loop number 1 This is loop number 2 This is loop number 3

d)

This is loop number 2 This is loop number 3 This is loop number 4 This is loop number 5

20.

What is the formula to calculate the average of a set of numbers?

a)

Sum of numbers × number of times

b)

Total ÷ number of times

c)

Total + number of times

d)

Sum of numbers - number of times

21.

If you have the numbers 2 and 2, what is their average?

a)

2

b)

3

c)

4

d)

5

22.

In the given code example, what is the initial value of the variable 'total'?

a)

1

b)

2

c)

0

d)

10

23.

What is the average of the numbers 10 and 20 in the provided code example?

a)

10

b)

15

c)

20

d)

25

24.

What is the purpose of rounding a number?

a)

To increase the number of digits

b)

To make calculations more complex

c)

To get a shorter answer

d)

To make numbers harder to read

25.

In the given code, what is the purpose of the line "birds=int(birds)"?

a)

To convert the input into a string

b)

To convert the input into an integer

c)

To add the input to the total

d)

To print the number of birds

26.

What is the output of the code "print(round(4.6))"?

a)

4.5

b)

4

c)

5

d)

6

27.

Why do we use the "round" function in programming?

a)

To make numbers more complex

b)

To simplify numbers using fewer digits

c)

To increase the number of decimal places

d)

To make numbers less readable

28.

Image of a code snippet calculating the average number of birds

a)

Calculating the average number of birds

b)

Finding the maximum number of birds

c)

Counting the total number of birds

d)

Sorting the number of birds

29.

How many values will the user enter?

a)

1

b)

2

c)

3

d)

4

30.

Change it to calculate the average value of the user input and round the total number.

a)

Use the sum function

b)

Use the round function

c)

Use the average function

d)

Use the multiply function

31.

What is the starting value of x in the given code?

a)

0

b)

1

c)

3

d)

5

32.

How many values will the user enter according to the code?

a)

1

b)

2

c)

3

d)

4

33.

What happens to variable x in each loop iteration?

a)

It is multiplied by the input value.

b)

It is divided by the input value.

c)

It adds each new input value to x.

d)

It subtracts the input value from x.

34.

What does the code calculate after the loop ends?

a)

The sum of the values

b)

The average of the values

c)

The product of the values

d)

The difference of the values

35.

What is the purpose of a conditional loop in programming?

a)

To execute a block of code a fixed number of times

b)

To execute a block of code as long as a condition is true

c)

To execute a block of code only once

d)

To execute a block of code in reverse order

36.

What is an infinite loop?

a)

A loop that runs a fixed number of times

b)

A loop that never starts

c)

A loop that never stops

d)

A loop that runs backwards

37.

In the given code snippet, what is the initial value of the variable 'total'?

a)

1

b)

3

c)

0

d)

10

38.

What should you do to stop a 'while' loop from becoming infinite?

a)

Never change the condition

b)

Change the condition to false at some point

c)

Use a 'for' loop instead

d)

Remove the loop entirely

39.

What is the purpose of asking the user if they want to continue in a loop?

a)

To make the loop run forever

b)

To stop the loop if the user says 'no'

c)

To change the loop to a 'for' loop

d)

To print a message

40.

What is the initial value of 'cupcakes' in the given while loop?

a)

0

b)

1

c)

5

d)

6

41.

How many times will the message "yummy" be printed in the given loop?

a)

3 times

b)

4 times

c)

5 times

d)

6 times

42.

What happens when the value of 'cupcakes' becomes 6 in the loop?

a)

The loop continues

b)

The loop stops

c)

The loop restarts

d)

The loop prints an error

43.

What type of loop is this?

a)

For loop

b)

While loop

c)

Do-while loop

d)

Infinite loop

44.

What comparison operator is used in the header? What is its meaning?

a)

==

b)

!=

c)

<

d)

<

45.

Give an example of an input that will stop the loop.

a)

"yes"

b)

"no"

c)

"continue"

d)

"stop"

46.

Write a code to stop when x is less than 10.

a)

while x < 10:

b)

while x > 10:

c)

if x < 10:

d)

if x > 10:

47.

What is the purpose of the "if" block in the given code?

a)

To repeat actions indefinitely

b)

To make decisions based on conditions

c)

To store data

d)

To create a loop

48.

In the block-based code, what happens when the condition is true?

a)

The program stops

b)

The program plays a sound

c)

The program moves 10 steps

d)

The program waits

49.

What is the role of the "else" block in the code?

a)

To execute code when the condition is false

b)

To repeat the previous action

c)

To end the program

d)

To store a variable

50.

What will the following code print if the weather is 'Sunny'?

a)

Wear sunglasses

b)

Wear a coat

c)

Wear a hat

d)

Wear boots

51.

What is the purpose of the following code snippet?

a)

To check if someone can drive

b)

To check if someone can vote

c)

To check if someone can drink

d)

To check if someone can work

52.

If the weather is cold, what should you wear according to the diagram?

a)

T-shirt

b)

Sweater

c)

Sunglasses

d)

Shorts

53.

What will the following code print?

a)

Nothing

b)

hurray!

c)

Error

d)

10

54.

What is Artificial Intelligence (AI)?

a)

A computer system that thinks and makes decisions like humans.

b)

A type of animal that can talk.

c)

A new kind of smartphone.

d)

A video game character.

55.

What is an example of Artificial Intelligence?

a)

Siri and face recognition.

b)

A bicycle.

c)

A refrigerator.

d)

A pencil.

56.

What is an expert system?

a)

A computer program that thinks like an expert to help people make decisions or find answers.

b)

A type of robot that cleans houses.

c)

A video game console.

d)

A new kind of television.

57.

How does an expert system help people?

a)

By asking questions and providing answers like a smart helper.

b)

By cooking food.

c)

By playing music.

d)

By painting pictures.

58.

What is one advantage of using an Expert System?

a)

It requires constant human supervision.

b)

It helps people find answers quickly.

c)

It forgets information easily.

d)

It is slow and unreliable.

59.

What does bias in a system mean?

a)

The system is always accurate.

b)

The system is fair and balanced.

c)

The system is not fair due to wrong or limited information.

d)

The system is based on complete information.

60.

Which component is NOT part of an Expert System?

a)

Knowledge Base

b)

Inference Engine

c)

Interface

d)

Random Access Memory

61.

What is a decision tree compared to?

a)

A list of items

b)

A map that helps you choose

c)

A book of rules

d)

A set of instructions

62.

Why is it called a "tree" in a decision tree?

a)

Because it grows leaves

b)

Because it branches out

c)

Because it is green

d)

Because it has roots

63.

In a decision tree, what does each question represent?

a)

A leaf

b)

A branch

c)

A root

d)

A trunk

64.

What question does the decision tree start with?

a)

Does the bird have white feather?

b)

Does the bird have a beak?

c)

Does the bird fly?

d)

Does the bird sing?

65.

According to the decision tree, what bird is identified if it does not have white feathers and is not a sparrow?

a)

Crow

b)

Seagull

c)

Sparrow

d)

Parrot

66.

In the example code, what is printed if the animal has 4 legs and barks?

a)

It's a dog!

b)

It's a cat!

c)

It's a bird!

d)

It's a fish!

67.

What does the example code print if the animal does not have wings?

a)

It's a fish!

b)

It's a bird!

c)

It's a dog!

d)

It's a cat!