Page 38 - tp_Modula_v2.0
P. 38
Program 6: To display one of the two alternate messages.
Program6.py
File Edit Format Run Options Window Help
#program to display one of two alternate messages
my_score = int(input('Enter a score:'))
passing_score = 60
if (my_score >= passing_score):
print('Congratulations on passing the exam')
else:
print('You failed, try harder next time')
On running the above program, you will get the following output:
Output
Enter a score:55
You failed, try harder next time
Enter a score:87
You failed, try harder next time
Program 7: To check if the given number is lucky or not, if the given number is greater
than zero and is even, then print ‘Lucky number’ else print ‘Not a lucky number’.
Program7.py
File Edit Format Run Options Window Help
#program to check lucky number
number = int(input('Enter a number: '))
if (number > 0):
if(number % 2 == 0):
print('Lucky number')
else:
print('Not a Lucky number')
else:
print('Try again')
36 Touchpad MODULAR (Version 2.0)

