- 1

give the answer with explain. b=20 while True:     if b<9:         break     b=b-9 print(b)

Give the explain of this code https://code.sololearn.com/cBrITpTxuJz3/?ref=app https://code.sololearn.com/Wnv4dum5u6E7/?ref=app

24th Apr 2020, 2:54 AM
sumaiya sharmin
sumaiya sharmin - avatar
1 Answer
0
Output will be : 11 2 It's because the print statement is inside the while block, thus the value of variable 'b' gets 20-9= 11 and prints it, goes back inside the while block and performs the operation, where it gets 2 (11-9=2) which is less than 9, thus it breaks out of loop.
24th Apr 2020, 3:40 AM
Aril Sirohi
Aril Sirohi - avatar