Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q13 of 15
Python - Basics and Execution Environment
What will be the output of this code?
print('Start')
for i in range(2):
    print(i)
print('End')
AStart\n0\n1\nEnd
BStart\n1\n2\nEnd
C0\n1\nStart\nEnd
DStart\nEnd
Step-by-Step Solution
Solution:
  1. Step 1: Trace the print and loop execution

    The first print outputs 'Start'. The loop runs with i=0 and i=1, printing each. Then 'End' is printed.
  2. Step 2: Write the output line by line

    Output lines are: Start, 0, 1, End.
  3. Final Answer:

    Start\n0\n1\nEnd -> Option A
  4. Quick Check:

    Loop prints 0 and 1 between Start and End [OK]
Quick Trick: Remember range(2) gives 0 and 1 [OK]
Common Mistakes:
MISTAKES
  • Assuming range(2) starts at 1
  • Ignoring the initial and final print statements
  • Confusing loop variable values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes