Introduction
Python Data Types & Operators
Conditional Statements
Python Loops
Python Strings
Python Lists
Python Tuple
if-else Statement
An if……else statement works on the following principle,
- execute the block of code inside if statement if the expression evaluates True. After execution return to the code out of the if……else block.
- execute the block of code inside else statement if the expression evaluates False. After execution return to the code out of the if……else block.
Example:
age=int(input("enter the age of a person"))
if age>=18:
print("you are eligible for voting") # indentation 4 space
else:
print("you are not eligible for voting")
Output:
enter the age of a person 17
you are not eligible for voting