QUESTION IMAGE
Question
question 10
what is printed?
for i in range(3):
if i == 1:
break
print(\loop\, i)
loop 0 loop 2
loop 0 loop 1
loop 1
loop 0
Step1: Analyze the loop
The range(3) generates values \(i = 0,1,2\).
Step2: First iteration (\(i = 0\))
Since \(i
eq1\), the break statement is not executed. So, "Loop 0" is printed.
Step3: Second iteration (\(i = 1\))
The condition \(i == 1\) is true. The break statement terminates the loop immediately.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
Loop 0