+ 2
What is the output of this code ? Please explain it
a=2 b=0 While(a or b) a -=1 Print (a)
3 Respostas
+ 8
https://code.sololearn.com/cCFtHcxPB1MW/?ref=app I also corrected mistakes.
+ 3
In python, any numeric value of zero (e.g. 0, 0.0) is considered False.
1st iteration:
while(2 or 0) //True
decrement 2 by 1
print 1
2nd iteration:
while(1 or 0) //True
decrement 1 by 1
print 0
3rd iteration:
while(0 or 0) //False
loop stops so statements inside loop are not executed
+ 1
you could try it in the playground.