Summary of the chapter “If statements in Python”. In this chapter we have looked at the basics of conditional statements that allow you to decide what will happen in the program depending on the state of a Boolean expression (True or False). We do this with the if, elif and else statements.
The conditional statements are evaluated by conditions. The terms can have two states, true, or false. If the condition is true, the condition statement will be executed, or if the condition statement is false, then the condition statement will not be executed.
A condition statement in Python always starts with an if condition. If the if condition is true, then all the operation belonging to the if statement will be performed. However, the if condition is false, the program skips all operations in the if statement and proceeds to the else if statements accordingly. If none of the if or else if statements are fulfilled, then the operations in the else statement will be performed.
With the help of if-statements we can: