0

Can someone explain each line.

i = 0 while 1==1: print(i) i = i + 1 if i >= 5: print("Breaking") break print("Finished")

14th Jul 2016, 2:24 PM
Musthaque Ch
Musthaque Ch - avatar
3 Antworten
+ 1
1) I=0 initialize a variable with starting value zero. 2) And while 1==1 stands for execute the loop while the value is true. 3)For true value print the value of i variable. 4)i=i+1 is used for incrementing the value of i so that loop can run for different value. 5) And if i>=5 the break the statement by 'break' statement.
14th Jul 2016, 2:37 PM
Shriram Moond
Shriram Moond - avatar
0
the while loop will continue until i will be 5 because when i will be 5 the break statement under if clause will be executed and it will come out from loop.. so the result will be 012345 Breaking Finished
14th Jul 2016, 3:37 PM
Subhankar Paul
Subhankar Paul - avatar
0
12345 Breaking Finished
14th Jul 2016, 3:47 PM
Murali Gandham
Murali Gandham - avatar