Page 245 - Ai_V1.0_Class9
P. 245
Nested if Statement
Writing one if statement within another if is called nested if statement. Nesting of if statement can be upto
any level. Indentation plays a very important role in identifying the levels.
Program 5: Write a Python program to input the billing amount and the age of a person. If the billing
amount exceeds Rs. 10000 and the person is a senior citizen, a 15% discount will be applied. If the billing
amount exceeds Rs. 10000 and the person is not a senior citizen, a 10% discount will be applied. Otherwise,
no discount will be given. Calculate the billing amount accordingly.
Algorithm
Step 1 Start
Step 2 Input Amount, Age
Step 3 if Amount is more than 10000 then
Step 4 if Age is greater than or equal to 60 then
Display "Amount after 15% discount is ", Amount-(0.15*Amount)
Step 5 else
Display "Amount after 10% discount is ", Amount-(0.10*Amount)
Step 6 else
Display "Sorry! No Discount"
Step 7 Stop
Flowchart
START
Input
Amount, Age
Is No Display
Amount > "Sorry! No Discount"
10000?
Yes
Is No Display
Age >= 60? Amount = Amount-(0.10*Amount)
Yes
Display
Amount = Amount-(0.15*Amount)
STOP
Introduction to Python 243

