If Statement, Else, and the ‘elif’ in Python
![]()
In this tutorial, we will learn about the if-statement and how to perform different scenarios in our code based on a certain condition.
We will learn these concepts while solving a small problem.
Our problem for this tutorial is about calculating the price of a flight ticket, where the flat price for example is 100$ for everyone except for the children under 12 it’s 50$ and for seniors above 70, it’s 80$.
In our application, We will ask the user to enter his age and then we output the ticket price.