Using break and continue statements with while loop

Lesson Details:
June 29, 2020


I: Introduction

A: Python is a general-purpose programming language which used to build web applications and software systems.

II: Body

A: Using break and continue statements with while loop

III: Conclusion

I: Introduction

A: Python is a general-purpose programming language which used to build web applications and software systems. It’s used to process large amounts of data gracefully and efficiently. It has many features such as easy to learn, rapid development.

II: Body

A: Using break and continue statements with while loop

A: The while statement in python works similarly to a for statement. The only difference is, the condition is checked at the top of the loop instead of the bottom.

B: A while loop in python does not execute the body for the first time when the condition is false, but executes it once. When python encounters a while statement, it will look at the expression that follows the while keyword. If the expression is true, then python will execute the body of the loop. After python executes the body of the loop, python will check the expression again. If it is still true, python will execute the body again. This continues until the expression is false, at which point python moves on to execute other statements after it.

C: Break Statement : The break statement immediately breaks out of the loop and moves execution to the next statement in line. In this case it’s a colon “:”. When using break by itself outside of a loop, break just moves execution to that line.

D: Continue Statement : The continue statement immediately breaks out of the current iteration of a loop and goes on to the next iteration. In this case it’s the colon “:”.

III: Conclusion

loader
Course content