Exercises · Q3
Q.Differentiate between break and continue statements using examples.
Yanam CbseNCERTSubjective· 3mImportance★★★★★est
67% · 26/39 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →break jumps OUT of the loop altogether; continue jumps back to the TOP of the loop, skipping only the rest of the current iteration — shown by outputs "1 2" vs "1 2 4 5" on the same loop.
The idea. Both are jump statements that alter a loop's normal flow, but their scope of effect differs completely:
| Aspect | break | continue |
|---|---|---|
| Effect | Terminates the loop immediately | Ends only the current iteration |
| Control goes to | First statement AFTER the loop | The loop's next test/iteration |
| Remaining iterations | Abandoned | Still executed |
| Typical use | Stop searching once found; exit on a sentinel value | Skip unwanted cases (e.g. invalid items) but keep looping |
Example 1 — break:
for i in range(1, 6):
if i == 3:
break
print(i)
print("Loop over")
1
2
Loop over
Trace: i=1 prints, i=2 prints, i=3 triggers break — iterations 3, 4, 5 never happen and control lands on the print after the loop.
Example 2 — continue (same loop, one word changed):
for i in range(1, 6):
if i == 3:
continue
print(i)
print("Loop over")
1
2
4
5
Loop over
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.