Page 313 - Artificial Intellegence_v2.0_Class_9
P. 313
Output:
Enter your percentage :89
CONGRATULATIONS
You are awarded– 'Certificate of Excellence'
Program 2: To input day of the week and in case it is SUNDAY then extra cookie as a reward point to be
given with the order.
Algorithm Flowchart
Start
Input weekday START
if weekday is same as "SUNDAY" then
Display " Reward point - Chocolate Cookie FREE !"
Input Weekday
Stop
Is
Weekday No
Source Code: SUNDAY
weekday=input("Enter day of the week :")
Yes
if weekday=="SUNDAY":
print("Reward Point – Chocolate Cookie FREE !")
Display "Reward Point –
Chocolate Cookie FREE !"
Output:
Enter day of the week : SUNDAY
STOP
Reward Point – Chocolate Cookie FREE !
The if…else Statement
When the condition is True then the statements indented just below the if statement will be
executed and if the condition is False then the statements indented just below the else statement
will be executed. The else statement is optional and if required can be only one else statement in one
if block. The syntax to use the if…else statement is:
if (condition):
Statements for True
else:
Statements for False
Where,
• if and else are keywords.
• condition can be any relation or logical expression.
• statements are always indented and can be single or a block.
Introduction to Python 311

