0

what 1==1 means in while loop?

10th Aug 2019, 1:08 PM
Talha Hilal
Talha Hilal - avatar
5 odpowiedzi
0
i need to know the logic... like what does it represents; when we are initiating a variable let suppose i=0 while 1==1: i=i+1 print i
10th Aug 2019, 1:12 PM
Talha Hilal
Talha Hilal - avatar
0
while 1==1 will become an infinite loop, as 1 is always 1. That will never change.
10th Aug 2019, 1:12 PM
Paul Grasser
Paul Grasser - avatar
0
If we do: i=0 while 1==1: # This will become an infinite loop, as one will always equal one # Do not have loops like this without a break statement, which can be used to exit loops i=i+1 if i == 50: # Once i is 50 let's exit the loop break print i # Output: 50
10th Aug 2019, 1:16 PM
Paul Grasser
Paul Grasser - avatar
0
If you declare 1==1 than while loops run infinitly becz 1==1 is always true
10th Aug 2019, 1:40 PM
chotu sharma
chotu sharma - avatar
0
In 1 == 1, an equality operator is performed, and a boolean is returned. 1 == 1 -> True while will run it's code, and will return back to test the "1 == 1" condition again and repeat this, until the condition is False, a break statement is found, or the whole program is aborted.
10th Aug 2019, 4:25 PM
Seb TheS
Seb TheS - avatar