0
0
Pythonprogramming~20 mins

Break vs continue execution difference in Python - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Loop Control Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of break in a loop
What is the output of this Python code using break inside a loop?
Python
for i in range(5):
    if i == 3:
        break
    print(i)
A
0
1
2
3
4
B
1
2
3
C
0
1
2
3
D
0
1
2
Attempts:
2 left
💡 Hint
Remember, break stops the loop immediately when the condition is met.
Predict Output
intermediate
2:00remaining
Output of continue in a loop
What is the output of this Python code using continue inside a loop?
Python
for i in range(5):
    if i == 3:
        continue
    print(i)
A
0
1
2
4
B
0
1
2
3
4
C
0
1
2
3
D
1
2
3
4
Attempts:
2 left
💡 Hint
Think about what continue does: it skips the current loop iteration.
🧠 Conceptual
advanced
1:30remaining
Difference between break and continue
Which statement correctly describes the difference between break and continue in loops?
A<code>break</code> and <code>continue</code> both exit the loop immediately.
B<code>break</code> exits the entire loop; <code>continue</code> skips to the next iteration.
C<code>break</code> skips the current iteration; <code>continue</code> exits the loop.
D<code>break</code> pauses the loop; <code>continue</code> restarts the loop from the beginning.
Attempts:
2 left
💡 Hint
Think about what happens to the loop after each keyword is executed.
Predict Output
advanced
2:00remaining
Loop behavior with break and continue combined
What is the output of this code that uses both break and continue?
Python
for i in range(6):
    if i == 2:
        continue
    if i == 4:
        break
    print(i)
A
0
1
3
B
0
1
2
3
C
0
1
3
4
D
0
1
2
3
4
Attempts:
2 left
💡 Hint
Check the order of conditions and what each keyword does.
🧠 Conceptual
expert
2:30remaining
Effect of break and continue in nested loops
In nested loops, which statement is true about break and continue?
A<code>break</code> exits all loops; <code>continue</code> skips all remaining iterations of all loops.
B<code>break</code> and <code>continue</code> affect only the outermost loop.
C<code>break</code> exits only the innermost loop; <code>continue</code> skips to the next iteration of the innermost loop.
D<code>break</code> skips the current iteration of the outer loop; <code>continue</code> exits the inner loop.
Attempts:
2 left
💡 Hint
Think about which loop the keywords apply to when loops are inside each other.