Question

Write a Python program that reads in the month, day, and year of a date and...

Write a Python program that reads in the month, day, and year of a date and prints it in the
dd/mm/yyyy format or mm/dd/yyyy format, the format depending on the user’s preference. The
program also prints the message
It is a magic date
If the product of month and day is equal to the last two digits of the year. For example, April 20
1980 is a magic date because April (numeric value 4) multiplied by 20 is equal to 80, the last two
digits of 1980. But June 10, 1961 is not a magic date because 6 * 10 is 60, not 61.
The program reads a date in the first three steps given below.
1. The program first prompts for the month. The user enters a value between 1 and 12 (1 for
January, 12 for December, etc.)
2. It then asks for the day of the month. The user enters a value between 1 and 31. We assume
the user enters a day that is consistent with the month and year. For example, if the month is
November, the user will not enter 31.
3. The code then prompts for the year. The user enters the year as a four-digit number.
4. The program then asks the user to enter one of the two strings ddmmyy or mmddyy .
5. The program displays the date it read in in the dd/mm/yyyy format, if the user entered
ddmmyy in Step 4. Otherwise, it prints the date in the other format.
6. The program finally prints the message about the magic date.

Homework Answers

Answer #1
#python code
month=int(input("Enter month:"))
days=int(input("Enter days:"))
year=int(input("Enter year:"))

s=input("Enter ddmmyy for dd/mm/yyyy format or mmddyy for mm/dd/yyyy:")

#add a 0 if month and days are a single digit
if month / 10 < 1:
    month = "0" + str(month)
if days / 10 < 1:
    days = "0" + str(days)

if s == "ddmmyy":
    print(str(days) + "/" + str(month) + "/" + str(year))
else:
    print(str(month)+"/"+str(days)+"/"+str(year))

#for magic date
if int(month)*int(days) is year%100:
    print("It is a magic date")

OUTPUT

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Modify the Date class in Fig. 8.7 by adding a new method called nextDay() that increments...
Modify the Date class in Fig. 8.7 by adding a new method called nextDay() that increments the Date by 1 when called and returns a new Date object. This method should properly increment the Date across Month boundary (i.e from the last day of the month to the first day of the next month). Write a program called DateTest that asks the user to enter 3 numbers (one at a time) corresponding to Month, Day and Year. The first two...
design a program that prompts the user to enter a positive integer number and reads the...
design a program that prompts the user to enter a positive integer number and reads the user’s input. If the user input is not a positive number, the program should prompt them repeatedly until they enter a valid input. Once a valid input is received ,the program uses a loop to calculate the sum of the digits of the user’s input and displays the sum. For example, if the user enters the number 94311, the program should print the sum...
Write a program In python of Jupiter notebook That prompts the user to enter his/her first...
Write a program In python of Jupiter notebook That prompts the user to enter his/her first name, last name, and year of birth in a single string (in the format: fn;ln;yyyy), then calculates the age tell it to him/her after greeting him/her using the first name. Make sure to capitalize the user's first name, regardless of how he/she typed it in. Hint: review Exercise 1! Example: Enter your first name, last name, and birth year (in format fn;ln;yyyy): alex;smith;1994 Hi...
Write a program that prompts the user to enter an integer number between 1 and 999....
Write a program that prompts the user to enter an integer number between 1 and 999. The program displays the sum of all digits in the integer if the input is valid; otherwise, it displays a message indicating that the integer is not between 1 and 999 and hence, is invalid. Name the program file Q1.cpp Example: if the user enters 12, sum of digits is 3. If the user enters 122, sum of digits is 5.
Python Jupyter Notebook Write a program that prompts the user to enter his/her first name, last...
Python Jupyter Notebook Write a program that prompts the user to enter his/her first name, last name, and year of birth in a single string (in the format: fn;ln;yyyy), then calculates the age tell it to him/her after greeting him/her using the first name. Make sure to capitalize the user's first name, regardless of how he/she typed it in. Hint: review Exercise 1! Example: Enter your first name, last name, and birth year (in format fn;ln;yyyy): alex;smith;1994 Hi Alex, you...
Vowels and consonants Write a program that reads a word and prints the number of vowels...
Vowels and consonants Write a program that reads a word and prints the number of vowels and consonants in the word. For this exercise assume that ‘a’, ‘e’, ‘i’, ‘o’, ‘u’, and ‘y’ are vowels. For example, if the user enters the input “Harry”, the program should print “The word contains 2 vowels and 3 consonants”.
(C Programming Language) (MULTIPLE FORMS – HAPPY BIRTHDAY MESSAGE) Write a Visual Basic program to request...
(C Programming Language) (MULTIPLE FORMS – HAPPY BIRTHDAY MESSAGE) Write a Visual Basic program to request a date in the form of mm/dd/yyyy. If your date of birth is entered, display on a second Form the message                                                 BEST DATE IN HISTORY !                                                 HAPPY BIRTHDAY TO ME !! For any other date, display on a third Form the message                                                 Just Another Day.                                                 No Big Deal. Demonstrate your working program for the Instructor. Include a commented listing with...
Write a program that asks the user for a number in the range 1 through 12....
Write a program that asks the user for a number in the range 1 through 12. The program should display the corresponding month of the year, where 1 = January, 2 = February, 3 = March, 4 = April, 5 = May, 6 = June, 7 = July, 8 = August, 9 = September, 10 = October, 11 = November, and 12 = December. The program should display an error message if the user enters a number that is outside...
Create your own date class. Create a MyDate class with these methods. A constructor that accepts...
Create your own date class. Create a MyDate class with these methods. A constructor that accepts a month, day, and year A method that determines if the year is a leap year A method that returns the date in this format, "1/9/2020" A method that returns the date in this format, "January 9, 2020" A method that returns the day A method that returns the name of the month A method that returns the number of days in the month...
Write a program that asks the user to enter an odd number and prints out a...
Write a program that asks the user to enter an odd number and prints out a triangle pattern. For example, if the user enters 5, the output is note: There is one space between the numbers in each line 1 3 5 1 3 1 If the user enters 9 the output is: 1 3 5 7 9 1 3 5 7 1 3 5 1 3 1 program language: C++