Page 400 - Ai_417_V3.0_C9_Flipbook
P. 400
Step 5 else Flowchart
Display "You entered -ve Number" START
Step 6 Stop
Input Num
Source Code:
Num=int(input("Enter a number:"))
Is Yes Display
if Num==0 :
Num == 0? "Zero"
print("You entered zero")
No
elif Num >0 :
print("You entered a positive number") Is Yes Display
Num > 0?
else: "+ve No"
print("You entered a negative number")
No
Output: Display
"–ve No"
Enter a number: –4
You entered a negative number
STOP
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 9: 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
398 Touchpad Artificial Intelligence (Ver. 3.0)-IX

