Page 89 - TP-Play_V-2.0_Book-7
P. 89
NESTED IF STATEMENT
Python allows the nested if statement. This means the if indented block inside another if…else
indented block. The second nested if indented block will run only when the first if condition
evaluates to be true. The syntax of nested if statement is shown below:
Syntax:
if (Test Expression1): False
Test Expression 1 Indented block 3
if (Test Expression2):
Indented block 1 True
else:
False
Test Expression 2 Indented block 2
Indented block 2
else: True
Indented block 3
Indented block 1
Statement just below if
Program 5: To find out if the student is selected for the college or not based on the given
conditions
1. Selected if age > 18 and marks > 65
2. Not selected if age > 18 and marks < 65
3. Not selected if age < 18
Conditional Statements in Python 89

