0
Why is output 11?
x = 0 c = 0 while x<=20 : x =x+2 c = c+1 print(c)
9 Réponses
+ 9
x = 0 and increase 2 atime
while C is 0 and increase 1 a time
x will keep 10 times(*2) then it will be 20 and the loop will make it increase once again because it is equal to 20 so the c will get more more and will be 11
x = 22 greater than 20 so the loop stops while c is now 11
+ 8
🌻Emàâââ🌻 ,
please do not post duplicated questions.
+ 1
I saw this in my teacher's old exam and i don't know why is the answer is 11 so i asked for help
+ 1
Lothar
yeah, i was like what the heck i just answered that question, i hope the answer wasn't just removed hehehe
+ 1
🌻Emàâââ🌻
simple answer, the loop will work 11 times until x become not equal and not smaller than 20
and the c will become 11 because the loop worked 11 times
+ 1
x = 0, 2, 4, 6, 8, 10, 12, 14 , 16, 18, 20
This are the 11 conditions for which loop will run that's why the value of c will be incremented 11 times and answer will be 11 👍
+ 1
Because it's less than and equal to
0
Thank u so much 🙏🏻
0
Maybe you saw my post because i posted it two time