Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q4 of 15
Python - For Loop
What will be the output of this code?
count = 0
while count < 3:
    print(count)
    count += 1
A0 1 2 3
B1 2 3
C0 1 2
D1 2
Step-by-Step Solution
Solution:
  1. Step 1: Trace the while loop iterations

    count starts at 0, prints 0, then increments to 1, repeats until count is 3 (not printed).
  2. Step 2: List printed values

    Printed values are 0, 1, 2 before loop stops.
  3. Final Answer:

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

    Loop prints count while less than 3 [OK]
Quick Trick: Loop stops before count reaches 3 [OK]
Common Mistakes:
MISTAKES
  • Including 3 in output
  • Starting count from 1
  • Missing increments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes