Page 39 - tp_Modula_v2.0
P. 39
On running the above program, you will get the following output:
Output
Enter a number: 8
Lucky number
Enter a number: 9
Not a Lucky number
Enter a number: -6
Try again
Program 8: To print the message based on the marks entered. Display the messages:
1. ‘Sorry!!!, You are failed in the exam’, if the marks are less than 35.
2. If the marks are less than or equal to 60 display the message ‘Passed with C grade’.
3. If the marks are greater than 60 and less than or equal to 85 display the message
‘Passed with B grade’.
4. If none of the condition evaluates to true, then display the message ‘Passed with A grade’.
Program8.py
File Edit Format Run Options Window Help
my_marks = int(input('Enter the marks: '))
if(my_marks < 35):
print('Sorry!!!, you are fail in the exam')
elif(my marks <= 60):
print('Passed with C grade')
elif(my_marks > 60 and my_marks <= 85):
print('Passed with B grade')
else:
print('Passed with A grade')
On running the above program, you will get the following output:
Output
Enter a marks: 55
Passed with C grade
Enter a marks: 65
Passed with B grade
Enter a marks: 86
Passed with A grade
Conditional Statements in Python 37

