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
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.
Write a python program that does the following: Prompts the user for three numbers in one...
Write a python program that does the following: Prompts the user for three numbers in one request. Be sure to specify the “delimiter” by which a user enters those three numbers. Divides the first number by the second number and add that result to the third number. Prints output that shows in one line the formula applied and the result of the calculation. Validate input by: •    Checking the user entered 3 values •    Appropriately checking for the following errors:...
February 18 is a special date for the CCC this year. Write a program that asks...
February 18 is a special date for the CCC this year. Write a program that asks the user for a numerical month and numerical day of the month and then determines whether that date occurs before, after, or on February 18. If the date occurs before February 18, output the word Before. If the date occurs after February 18, output the word After. If the date is February 18, output the word Special. Input The input consists of two integers...
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
B.2. Write a Java program to display a dialog box that asks you to enter your...
B.2. Write a Java program to display a dialog box that asks you to enter your user name and the age as shown below: The program displays in a dialog box the sum of digits of your age. For example, if you age is 19, the sum will be 1+9 = 10 and the output will be as shown below: ( it just shows a message box that says the sum of the digits age of john is 10.
Write the following in Java In this section, you will overload methods to display dates. The...
Write the following in Java In this section, you will overload methods to display dates. The date-displaying methods might be used by many different applications in an organization, such as those that schedule jobs, appointments, and employee reviews. The methods take one, two, or three integer arguments. If there is one argument, it is the month, and the date becomes the first day of the given month in the year 2020. If there are two arguments, they are the month...
public class Date {    private int month;    private int day;    private int year;...
public class Date {    private int month;    private int day;    private int year;    public Date( int monthValue, int dayValue, int yearValue )    {       month = monthValue;       day = dayValue;       year = yearValue;    }    public void setMonth( int monthValue )    {       month = monthValue;    }    public int getMonth()    {       return month;    }    public void setDay( int dayValue )    {       day =...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
Need this program in Java Develop (using C++ or Java language) the software application described below....
Need this program in Java Develop (using C++ or Java language) the software application described below. Write a program that prints the day number of the year, given the date is in the form month-day-year. For example, if the input is 1-1-09, the day number is 1; if the input is 12-25-09, the day number is 359. The program should check for a leap year. A year is a leap year if it is divisible by 4 but not divisible...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT