Nested If Statement
For many scenario, it's not only have a multiple decision-making condition, it's also include nested decision making.

Usage
if meet_condition_1:
do action_1
if meet_condition:
do action_2Example
nested-if.py
- Example Scenario: In a station of theme park, the
game priceisbased on customer's heightandvip status, butvip statusonly ask when thecustomer's heightis not full-filled.
py
customers_height = float(input("Please enter your height in cm: "))
# vip status >= 3 or height <= 150cm free to play
if customers_height > 150:
print("You can play this game for free, if you are vip member")
vip_status = int(input("Please enter your vip status (1 - 5): "))
if vip_status >= 3:
print("Since you are vip, you are free even your height is over")
else:
print("You have to pay for this game, amount required to pay - $ 10")
else:
print("You are for this game, since your height are <= 150 cm")Results:
Trial 1: (height = 150, vip_level = 0)
Input Required: customers_height
Please enter your height in cm: 150
You are for this game, since your height are <= 150 cmTrial 2: (height = 170, vip_level = 1)
Input Required: customers_height, vip_status
Please enter your height in cm: 170
You can play this game for free, if you are vip member
Please enter your vip status (1 - 5): 1
You have to pay for this game, amount required to pay - $ 10Trial 3: (height = 170, vip_level = 5)
Input Required: customers_height, vip_status
Please enter your height in cm: 170
You can play this game for free, if you are vip member
Please enter your vip status (1 - 5): 5
Since you are vip, you are free even your height is over