While loop in python

 WHILE LOOP

"While loop" is also a loop function, which helps to do a specific work one by one in loop, this loop is based upon the conditions is must be true, it breaks only when the condition is equals or false.
Code👇
i= 0
while(i<45):
print(i)

0
0
0
0
...
    here the number is initialised by the "0".
i= 1
while(i<7):
print(i)
i = i + 1
1
2
3
4
5
6
    Here, the given "i" is continuously increments by "1".

To print a table of 6

Code👇
i=6
while(i<66):
print(i)
i = i + 6
6
12
18
24
30
36
42
48
54
60
    note: Here in "while loop" the last given number will always get decremented as here the number "66".

Comments

Popular Posts