निम्नलिखित का आउटपुट क्या है?
What is the output of the following ?
n=5
while n>0:
n-=1
if n ==2:
continue
print(n)
A)
B)
C)
D)
Explanation:
Sure! Here's a simpler explanation:
- Initially,
n = 5
. - The loop runs while
n > 0
, and in each iteration,n
is reduced by 1. - When
n == 2
, thecontinue
skips printingn
and 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