Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q13 of 15
Python - For Loop
What will be the output of this code?
for i in range(3):
    print(i)
A0 1 2
B1 2 3
C0 1 2 3
D3 2 1
Step-by-Step Solution
Solution:
  1. Step 1: Understand range(3) values

    range(3) generates numbers 0, 1, 2.
  2. Step 2: Print each value in loop

    The loop prints each number on its own line: 0, then 1, then 2.
  3. Final Answer:

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

    range(3) = 0,1,2 [OK]
Quick Trick: range(n) starts at 0 up to n-1 [OK]
Common Mistakes:
MISTAKES
  • Thinking range(3) starts at 1
  • Including 3 in output
  • Reversing order of numbers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes