+ 1
Please explain this code.
x = 3 y = 1 while x>0: y=y+x x=x-2 print (y)
2 Réponses
+ 1
Hi Allamprabhu Hiremath
x=3
y=1
while x>0:
y=y+x
x=x-2 #print(y)
First, 3>0; so y=1+3=4
Second, 1>0; so y=4+1=5
Third, -1<0; so loop stops.
Therefore, print(y)=5
+ 2
Thank you