Learn with Yasir

Share Your Feedback

Python Loop Control MCQs – Break, Continue

Sharpen your Python skills with multiple-choice questions on loop control statements. Practice break, continue, and else with real coding scenarios.

Topic: loop-control-statements


📝 Multiple Choice Questions

🟢 Beginner

Q1. What is the output of the following code snippet?

for i in range(5):
    if i == 3:
        continue
    print(i)
  • 🟢 A. 0 1 2 3
  • 🔵 B. 0 1 2 4
  • 🟠 C. SyntaxError: invalid syntax
  • 🔴 D. IndentationError: expected an indented block
Answer

0 1 2 4

The continue statement skips iteration when i==3, so 3 is not printed.


Q2. What is the output of the following code snippet?

for i in range(5):
    if i == 3:
        break
    print(i)
  • 🟢 A. 0 1 2
  • 🔵 B. 0 1 2 3
  • 🟠 C. 1 2 3
  • 🔴 D. 0 1 2 3 4
Answer

0 1 2

The break statement exits the loop completely when i==3.


🟡 Intermediate

Q1. What is the output of the following code?

i = 0
while i < 5:
    i += 1
    if i == 3:
        break
    print(i)
else:
    print("Loop completed")
  • 🟢 A. 1 2
  • 🔵 B. 1 2 Loop completed
  • 🟠 C. 1 2 3
  • 🔴 D. 1 2 3 Loop completed
Answer

1 2

The break exits the loop before completion, so the else clause doesn't execute.


Q2. What does the 'break' statement do in a while loop?

  • 🟢 A. Pauses the loop for 1 second
  • 🔵 B. Skips to the next iteration
  • 🟠 C. Exits the loop immediately
  • 🔴 D. Restarts the loop
Answer

Exits the loop immediately

The break statement exits the entire loop structure regardless of the loop condition.


Q3. What does the 'break' statement do in a while loop?

  • 🟢 A. Pauses the loop for 1 second
  • 🔵 B. Skips to the next iteration
  • 🟠 C. Exits the loop immediately
  • 🔴 D. Restarts the loop
Answer

Exits the loop immediately

The break statement exits the entire loop structure regardless of the loop condition.


Q4. What does this loop print?

for char in "Python":
    if char == 'h':
        break
    print(char, end='')
  • 🟢 A. Python
  • 🔵 B. Pyt
  • 🟠 C. Pyth
  • 🔴 D. Pytho
Answer

Pyt

The loop breaks when it encounters 'h'.


Q5. Which statement immediately exits a for loop?

  • 🟢 A. stop
  • 🔵 B. exit
  • 🟠 C. break
  • 🔴 D. return
Answer

break

The break statement exits the nearest enclosing loop.


🔴 Advanced

Q1. What will this code output?

x = 5
while x > 0:
    x -= 1
    if x == 2:
        continue
    print(x, end=' ')
  • 🟢 A. 4 3 2 1 0
  • 🔵 B. 4 3 1 0
  • 🟠 C. 5 4 3 2 1
  • 🔴 D. 4 3 1 0 -1
Answer

4 3 1 0

The continue skips printing when x is 2, and the loop stops when x reaches 0.


Q2. What is the value of x after this loop?

x = 0
for i in range(5):
    if i % 2 == 0:
        continue
    x += i
  • 🟢 A. 0
  • 🔵 B. 4
  • 🟠 C. 6
  • 🔴 D. 10
Answer

4

Only odd numbers (1 and 3) are added to x (1+3=4).


🧠 Practice & Progress

Explore More Topics

📘 Learn Python

Tutorials, Roadmaps, Bootcamps & Visualization Projects

Python Fundamentals

Flow Control Statements


Python Functions


Fundamentals more ...




🧠 Python Advanced

Object-Oriented Programming in Python (OOP)

More...

🧠 Modules