निम्नलिखित का आउटपुट क्या है?
What is the output of the following ?
for i in range(10):
if i == 5:
break
else:
print(i)
else:
print("Here") A
0 1 2 3 4 Here
B
0 1 2 3 4 5 Here
C
0 1 2 3 4
D
1 2 3 4 5
Explanation
Sure! Here's a simple breakdown:
- The
forloop runs fromi = 0toi = 9. - When
ireaches 5, thebreakstatement stops the loop. - The numbers
0 1 2 3 4are printed because the loop ends beforeireaches 5. - The
elseafter the loop is not executed because the loop was stopped withbreak.
Output:
(C) 0 1 2 3 4
Correct Answer: C) 0 1 2 3 4