Page 305 - AI Ver 1.0 Class 9
P. 305
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 7: To input billing amount and gender. If the billing amount is more than 10000 and gender is
female, then discount is 15% otherwise discount is 10%. Calculate the billing amount accordingly.
Algorithm
Start
Input Amount, Gender
if Amount is more than 10000 then
if Gender is same as that of "F" then
Display "Amount after 15% discount is ", Amount-(0.15*Amount)
Otherwise
Display "Amount after 10% discount is ", Amount-(0.10*Amount)
Otherwise
Display "Sorry! No Discount"
Stop
Flowchart
START
Input
Amount, Gender
Is No Display
Amount > "Sorry! No Discount"
10000
Yes
Is No Display
Gender = "F" Amount = 0.10* Amount
Yes
Display
Amount = 0.15* Amount
STOP
Source Code:
Amount=int(input("Enter billing Amount: "))
gender=input("Gender :")
Introduction to Python 303

