Control Statements
Control statements in Python are constructs designed to manage the flow of your program's execution. They empower you to make choices, iterate actions, and bypass specific sections of your code contingent on particular conditions.
In python, there are three control statements given below:
- pass
- continue
- break
Pass Statement
When you write a loop, it can not be empty. You have to write some code in it. But if you do not want to write code and still need for loop, you can use pass statement to pass all the iterations to avoid getting error.
Continue Statement
In loops, continue statement is used to skip the current iteration. For example, we say that if counter variable has some specified value, then continue. It means that skip the iteration at specified value. The continue statements are executed along with if statement.
Break Statement
In loops, break statement is used to skip all iterations after the variable has a specified value. For example, we say that if counter variable has some specified value, then break. It means that skip all the iterations after that specified value. The break statements are executed along with if statement.
Practice Exercises
Complete these exercises to reinforce your learning and earn XP