Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q13 of 15
Python - Loop Control
What will be the output of this code?
for i in range(3):
    if i == 1:
        pass
    print(i)
A0 2
B1
C0 1 2
DSyntaxError
Step-by-Step Solution
Solution:
  1. Step 1: Understand the loop and pass usage

    The loop runs for i = 0, 1, 2. When i == 1, pass does nothing and the program continues.
  2. Step 2: Check what is printed each iteration

    Each iteration prints the current i value: 0, then 1, then 2.
  3. Final Answer:

    0 1 2 -> Option C
  4. Quick Check:

    pass does nothing, all i printed [OK]
Quick Trick: pass does nothing, so all loop prints run [OK]
Common Mistakes:
MISTAKES
  • Thinking pass skips printing
  • Expecting pass to break or continue loop
  • Confusing pass with a print statement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes