The if statements in Python is a so-called condition statement. It is a single or multiple statements that are performed depending on whether a logical precondition is fulfilled or not
The if statement is used to decide whether or not to perform an operation. If the condition is true, then the operation is performed. If the condition is false, the operation is not performed. The if statement can be combined with several if statements, so-called else-if and else statements.
The if statement is used to decide whether or not to perform an operation
In this chapter, we will go through how to combine if-statements with else-if and else-statements to create conditional programming. The flowchart illustrates whether or not an operation should be performed, depending on whether or not the condition in the if statement is met.
It might be a good idea to repeat and remind ourselves of the logical operators we saw in the previous chapter. These will be very useful when using the if statement.