+ 1

While Loop Question

View code only a couple lines The question is from a quiz https://code.sololearn.com/cV3d4F4114YO/?ref=app

11th Apr 2020, 3:13 AM
Leonardo Monterey
Leonardo Monterey - avatar
6 odpowiedzi
+ 4
Let's execute it line by line:- x=3 # x is assigned the value =3 y=4 # y have value 4 #bellow loop will run untill x and y both don't become equal while x!=y: print (x) # the program prints "x" which is "3" x=x+1 # x is incremented by one , so now x is 4 since now x==y so program will not execute while loop again(like Царь СОБАКА - Догго l said) and output will be "3"
11th Apr 2020, 3:22 AM
Arsenic
Arsenic - avatar
+ 2
Thats allot of info to process for a couple of lines but thanks I do understand the operation now.
11th Apr 2020, 3:37 AM
Leonardo Monterey
Leonardo Monterey - avatar
+ 1
How would the program read for it to print out 4
11th Apr 2020, 3:19 AM
Leonardo Monterey
Leonardo Monterey - avatar
0
EUREKA!!!!! I get it, (yeah I know, two day's later) I typed x=3 , y=7 and the progem kept running, until 6 . SOOOO!!!!! until x = 7 keep adding 1 if it reaches 7 (which we don't want it to) keep adding. When It reaches 7 which !not stop, Sooooooo.... the program stops running at 6. Wooooooow. The Bug was in my way of thinking .
12th Apr 2020, 6:49 PM
Leonardo Monterey
Leonardo Monterey - avatar