Python if Statement ΒΆ

In this tutorial, you will learn about the Python if...else statement with the help of examples to create decision-making programs.

Note

In computer programming, we use the if statement to run a block code only when a certain condition is met.
For example, assigning grades (A, B, C) based on marks obtained by a student.
if the percentage is above 90, assign grade A
if the percentage is above 75, assign grade B
if the percentage is above 65, assign grade C
In Python, there are three forms of the if...else statement.
if statement
if...else statement
if...elif...else statement