لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.
Lesson 17: If elif else Statements In Python
In Python if statement evaluates whether a condition is equal to true or false. The statement will execute a block of code if a specified condition is equal to true. Otherwise, the block of code within the if statement is not executed. Decision making is required when we want to execute a code only if a certain condition is satisfied. The if…elif…else statement is used in Python for decision making.
Example Code: If elif else Statements In Python.
Code
The above program speifies the output given 3 conditions as under.
Condition 1. if age = 18
you are an adult.
you can vote.
thank you.
Condition 2. age < 18 and age > 3
You are not eligible.
thank you.
Condition 3. else
You are a child
thank you.
print("thank you") is the common string for all the 3 given condition.
Now change the age variable in the code above and observe the output for different ages.
Condition 1 if: for age >= 18
Code
Condition 2 elif: for age < 18 and age > 3
Code
Condition 3 else: for any condition other than the above two situation.
Code