While loop in Python

Here we take i =0 and checks every time with some increment value
and we should have a check condition that the while loop checks
whether value of i satisfies it or not.The loop runs until the condition
is true and loop breaks when condition is false.


i=0
while (i<6):
    print(i)
    i+=3


Answer:

0


In this example we incremented at the rate of 3, for the first time i=0
increment value is 3 so i =0+3 then for the next iteration i=3
and later i=3+3 = 6 so the condition fails.
Loop breaks that is how while loop works in python

Comments

Popular posts from this blog

How to set text for a TextView in Android using Android Studio

Download Aarogya Setu Android || Corona || India

Compromising Gmail Password is way dangerous than we think!