SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Decision Structures And Boolean Logic
Exercise:
Programming Exercises
Question:4 | ISBN:9780132576376 | Edition: 2

Question

The date June 10, 1960, is special because when it is written in the following format, the month times the day equals the year:
6/10/60
Design a program that asks the user to enter a month (in numeric form), a day, and a twodigit year. The program should then determine whether the month times the day equals the year. If so, it should display a message saying the date is magic. Otherwise, it should display a message saying the date is not magic.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

CODE:

Month = int(input("Enter a month (in numeric form) :"))         #Asking the user to enter a month.
Day =  int(input("Enter a day :"))                              #Asking the user to enter a day.
Year = int(input("Enter a two-digit year:"))                    #Asking the user to enter a two-digit year.
Determine = Month * Day ==Year                                 #determine whether the month times the day equals the year.
if Determine:                              #determine whether the month times the day equals the year and check.                                                   
    print(" The date is magic.")                                #if it is true display message.
else:                                                                                                  
    print("The date is not magic.")                             #else display another message.

 

OUTPUT:

Enter a month (in numeric form) :6
Enter a day :10
Enter a two-digit year:60
 The date is magic.



Enter a month (in numeric form) :3
Enter a day :4
Enter a two-digit year:14
The date is not magic.

 

0 0

Discussions

Post the discussion to improve the above solution.