wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

while loop

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the purpose of a while loop?

a)

To execute a block of code based on a random condition

b)

To repeatedly execute a block of code as long as a specified condition is true.

c)


To execute a block of code only once

d)

To skip over a block of code

2.

Which loop do we use when we have to repeat a code unknown number of times?

a)


Repeat loop

b)

For loop

c)

Forever loop

d)

While loop

3.

What is the role of a counter variable in a loop?

a)

It is used to keep track of the number of iterations or the current position within the loop.

b)

It is used to skip iterations in the loop

c)


It is used to store the final result of the loop

d)


It is used to define the loop condition

4.

What value is assigned to the index variable when button A is pressed?

a)

0

b)

1

c)

4

d)

5

5.

What is plotted on the LED grid during the loop?

a)

The x-coordinate only.

b)

The y-coordinate only.

c)

Both x and y coordinates using the index value.

d)

Random coordinates.

6.

How many LEDs will be lit when button A is pressed?

a)

2 LEDs

b)

4 LEDs

c)

5 LEDs

d)

6 LEDs

7.

Which coordinate pattern is displayed on the LED grid as the code runs?

a)

A diagonal line from the top-left to the bottom-right.

b)

A vertical line.

c)

A horizontal line.

d)

A square pattern.

8.

Which type of numbers will be displayed by this code?

a)

Odd numbers only.

b)

Even numbers only

c)

Both even and odd numbers.

d)

Multiples of 10 only.

9.

What is the highest value that will be displayed by this code if count is set to 10?

a)

10

b)

19

c)

18

d)

20

10.

Which type of numbers will be displayed by this code?

a)

Odd numbers only.

b)

Even numbers only

c)

Both even and odd numbers.

d)

Multiples of 10 only.