निम्नलिखित का आउटपुट क्या है?
What is the output of the following ?
n=5
while n>0:
n-=1
if n ==2:
continue
print(n) A
5 4 3 1 0
B
4 3 1 0
C
4 3 2
D
None of these
Explanation
Sure! Here's a simpler explanation:
- Initially,
n = 5. - The loop runs while
n > 0, and in each iteration,nis reduced by 1. - When
n == 2, thecontinueskips printingnand moves to the next iteration.
Step-by-step output:
n = 5→ print 4n = 4→ print 3n = 3→ skip printing (becausen = 2)n = 1→ print 1n = 0→ loop ends
So the output is: 4 3 1 0
Answer: (B) 4 3 1 0
Correct Answer: B) 4 3 1 0