wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Loops

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

If I want a command to be inside of a loop, how many spaces should it be indented?

a)

1

b)

2

c)

3

d)

4

2.

Which of the following would be the best situation to use a for loop?

a)

To make a sprite say hi 5 times.

b)

To make the background flash different colors.

c)

To make a sprite move from one side of the screen to another.

d)

To check if the user input is a correct answer.

3.

While running this program, which direction will the sprite move?

a)

Up

b)

Down

c)

Left

d)

Right

4.

After running this program, what is the final value of x, assuming x = 0 at the beginning of the program?

a)

0

b)

1

c)

25

d)

100

5.

How many times will this loop run?

a)

4 times

b)

x times

c)

50 times

d)

200 times (50 * 4)

6.

Which of the following will tell the For loop how many times to run?

a)

Loop Range

b)

Loop Length

c)

List Length

d)

Integer Variable

7.

How many times will this loop run?

a)

0

b)

6

c)

60

d)

200

8.

Which of the following is a programming construct that allows us to repeat steps?

a)

conditional

b)

variable

c)

list

d)

loop

9.

If I want an action to be performed on every value in my list, what do I need?

a)

input variable

b)

loop through list

c)

conditional

d)

for loop with range

10.

I have the following list: ["red", "orange", "yellow"] What would I need to make the background change to each color in the list?

a)

If background_color == "red"

b)

stage.set_background_color("red")

c)

stage.set_background_color(value)

d)

If background_color == value

11.

What is the final value of the variable num?

a)

0

b)

2

c)

5

d)

10

12.

If I want an action to be performed a certain number of times, what do I need?

a)

input variable

b)

loop through list

c)

conditional

d)

for loop with range

13.

On which line of code is there an error in this program?

a)

Line 1

b)

Line 3

c)

Line 5

d)

Line 6

14.

What will this program do?

a)

The sprite will go from being very small to very big

b)

The sprite will start at the left, move towards the right and then move back to the left.

c)

The sprite will start at the bottom, move up, and then move back down.

d)

Nothing, there's an error in this program.

15.

Why are loops helpful to programmers?

a)

They let you save space in your code so you don't the same lines over and over again

b)

They free up more memory in your computer so everything runs faster

c)

They allow a program to store information to remember for later.

d)

They allow the program to see if a situation is true, and run code depending on that.