wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

2.2.2 - 2.2.3 Iteration Extra Practice

Total questions: 28

Worksheet time: 22mins

Name
Class
Date
1.

What is the main condition for a `while` loop to keep running?

a)

As long as a list is not empty

b)

As long as the condition is True

c)

Until the function ends

d)

As long as a variable is undefined

2.

What kind of loop runs indefinitely if the condition never becomes false?

a)

Controlled loop

b)

Break loop

c)

Infinite loop

d)

Timed loop

3.

What will this code print? counter = 0 while counter < 3: print(counter) counter += 1

a)

0 1 2

b)

1 2 3

c)

0 1 2 3

d)

1 2

4.

Which operator is typically used to check a condition in a `while` loop?

a)

+

b)

==

c)

=

d)

%

5.

What does a `for` loop iterate over?

a)

Only strings

b)

Only numbers

c)

A sequence

d)

A condition

6.

Which keyword is used to start a `for` loop in Python?

a)

iterate

b)

loop

c)

for

d)

range

7.

What is the correct structure for a `for` loop?

a)

for i = range(5)

b)

for i in range(5):

c)

loop i in range(5):

d)

for (i in range 5)

8.

Which situation is best for a `for` loop?

a)

Only strings

b)

Only numbers

c)

Iterating over a sequence

d)

A condition

9.

What does the `break` statement do?

a)

Pauses the loop

b)

Skips one loop cycle

c)

Ends the loop immediately

d)

Repeats the loop

10.

When is `break` commonly used?

a)

When a value reaches a limit

b)

To reset a loop

c)

To increase a variable

d)

In variable declarations

11.

True or False: `break` works in both `for` and `while` loops.

a)

True

b)

False

12.

How does `break` affect loop flow?

a)

Skips the current iteration

b)

Skips the next iteration

c)

Exits the loop

d)

Starts the loop over

13.

What does `continue` do in a loop?

a)

Skips all remaining code in the loop for this iteration

b)

Exits the loop

c)

Starts the program over

d)

Jumps to the end of the program

14.

When should you use `continue`?

a)

To stop a loop completely

b)

To handle an error

c)

To skip over part of the loop

d)

To create a variable

15.

True or False: The loop stops when it hits a `continue` statement.

a)

False

b)

True

16.

Where is `continue` typically used?

a)

At the top of the loop

b)

After the loop ends

c)

Inside a condition in the loop

d)

Outside of all code blocks

17.

What does the `pass` statement do?

a)

Ends a loop

b)

Acts as a placeholder

c)

Skips the loop

d)

Restarts the code

18.

Which situation is best for using `pass`?

a)

When code isn't written yet

b)

When checking conditions

c)

When skipping errors

d)

When comparing values

19.

What will this loop do? while True: pass

a)

Run once

b)

Print something

c)

Run forever

d)

Throw an error

20.

What is a nested loop?

a)

A loop with no end

b)

A loop inside another loop

c)

A loop that runs twice

d)

A loop with multiple conditions

21.

True or False: Nested loops can contain both `for` and `while`.

a)

True

b)

False

22.

How many times will this print run? for i in range(2): for j in range(3): print("Repeat")

a)

2

b)

3

c)

5

d)

6

23.

What is a compound condition?

a)

A condition that loops

b)

A condition using `and` or `or`

c)

A loop that breaks

d)

A placeholder

24.

Which is a compound conditional loop? while health > 0 and shield > 0:

a)

A loop with a single condition

b)

A loop with multiple conditions using `and`

c)

A loop that never ends

d)

A loop with no conditions

25.

Why use compound conditions in loops?

a)

To reduce code complexity

b)

To create errors

c)

To replace `break`

d)

To avoid using `for` or `while`

26.

A coach wants to track each lap during a 10-lap race. The loop should start at lap 1 and end at lap 10.
Fill in the blank code to complete the loop:

for lap in range(1, ____ ): print("Lap", lap, "complete")

4 lines
27.

A bakery tracks every batch of cookies it makes in a day. If they make 15 batches, starting with batch 1, how should the loop be written?

for batch in range(1,____): print("Batch", batch, "is cooling")

4 lines
28.

A marathon runner logs each kilometer in a 42-kilometer race. The log starts at kilometer 1 and goes to 42.

for km in range(1,____ ): print("You’ve reached kilometer", km)

4 lines