Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question 10 what is printed? for i in range(3): if i == 1: break print(…

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

Explanation:

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.

Answer:

Loop 0