If statements in Python – Summary

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 CONDITION IS EITHER TRUE OR FALSE

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.

IF, ELSE AND ELSE IF

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.

THE CONDITION STATEMENTS CONTROL OUR PROGRAMS

With the help of if-statements we can:

  • Control all programming with logic.
  • Control terms with Boolean expressions (true or false)
  • Decide the operations to perform or not