Question

In: Computer Science

python.Write a python program that prompts the user to enter the year and first day of...

python.Write a python program that prompts the user to enter the year and first day of the year, and displays the first day of each month in the year. For example, if the user entered the year 2020 and 3 for Wednesday, January 1, 2020, your program should display the following output:

January 1, 2020 is Wednesday

February 1, 2020 is Saturday ……

December 1, 2020 is Tuesday

Solutions

Expert Solution

Required program in python -->

days=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
year=int(input("Enter year"))
day=int(input("Enter day"))
if year % 4 == 0 and year % 100 != 0:
February=29
elif year % 100 == 0:
February=28
elif year % 400 ==0:
February=29
else:
February=28
print("January 1,",year," is ",days[day])
f=(day+31)%7
feb=days[f]
print("February 1,",year," is ",feb)
m=(f+February)%7
march=days[m]
print("March 1,",year," is ",march)
a=(m+31)%7
april=days[a]
print("April 1,",year," is ",april)
ma=(a+30)%7
may=days[ma]
print("May 1,",year," is ",may)
j=(ma+31)%7
june=days[j]
print("June 1,",year," is ",june)
ju=(j+30)%7
july=days[ju]
print("July 1,",year," is ",july)
au=(ju+31)%7
august=days[au]
print("August 1,",year," is ",august)
s=(au+31)%7
september=days[s]
print("September 1,",year," is ",september)
o=(s+30)%7
october=days[o]
print("October 1,",year," is ",october)
n=(o+31)%7
november=days[n]
print("November 1,",year," is ",november)
d=(n+30)%7
december=days[d]
print("December 1,",year," is ",december)

This program first take year as an input from user, then it checks whether a year is leap year or not, if it is leap year than it assigns February to 29, else to 28. Then we have a list from which we can count the days for each given month. We know jan has 31 days, march has 31 days, april has 30 days, like this, we find the remainder of days with 7, and then we access the list days[], and provide the output with suitable days.

o/p ->

Enter year2020                                                                                                                         

Enter day3                                                                                                                             

January 1, 2020  is  Wednesday                                                                                                         

February 1, 2020  is  Saturday                                                                                                         

March 1, 2020  is  Sunday                                                                                                              

April 1, 2020  is  Wednesday                                                                                                           

May 1, 2020  is  Friday                                                                                                                

June 1, 2020  is  Monday                                                                                                               

July 1, 2020  is  Wednesday                                                                                                            

August 1, 2020  is  Saturday                                                                                                           

September 1, 2020  is  Tuesday                                                                                                         

October 1, 2020  is  Thursday                                                                                                          

November 1, 2020  is  Sunday                                                                                                           

December 1, 2020  is  Tuesday       


Related Solutions

First, the Python program prompts user to enter user information (name, email, and phone number). Then...
First, the Python program prompts user to enter user information (name, email, and phone number). Then it displays a menu called “Fish Information” that has the following fish type: 1. Cat Fish 2. Red Fish 3. Any other fish Let user choose the fish type that he/she got and input the length of the fish. Then the program will determine what should be done with this particular fish. Based on the following criteria: Criteria: Length: FISHTYPE - Cat Fish <10:...
Write a Python program that prompts the user to enter a list of words and stores...
Write a Python program that prompts the user to enter a list of words and stores in a list only those words whose first letter occurs again within the word (for example, 'Baboon'). The program should display the resulting list..................please explain step by step
Write a program function code in Python that prompts the user to enter the total of...
Write a program function code in Python that prompts the user to enter the total of his/her purchase and add 5% as the VAT. The program should display the total without and with VAT. ( that mean i should ask the user to enter the number of their item " so i think that i should use range" then print the result with and without the VAT )
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program...
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program should display a letter grade for each score and the average test score. Hint: Declare local variables under main() program Prompts the user to enter 5 test scores Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg Define a function to determine the letter grade: this should accept a test score as argument...
Python A program which prompts the user to enter an number which is a integer n...
Python A program which prompts the user to enter an number which is a integer n and creates a tuple where the values are all numbers between 1 and n (both inclusive). Note: you can assume that the integer will always be > 1. Input Result 3 Enter an integer: 3 (1, 2, 3)
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter his/her favorite English saying, then counts the number of vowels in that (note that the user may type the saying using any combination of upper or lower case letters). Example: Enter your favorite English saying: Actions speak LOUDER than words. Number of wovels: 10
python programming. Write a program that prompts the user to enter an integer from 0 to...
python programming. Write a program that prompts the user to enter an integer from 0 to 9. The program will check if the input is a positive integer. It displays the correct answer and shows the guess is correct or not. The demos are shown as following.(Hint:1. Use a random math function 2. Use str.isdigit() to check the input)
Write a program that prompts the user enter a word, and determines the first half and...
Write a program that prompts the user enter a word, and determines the first half and second half of the word. Print the first and second half of the word on different lines. Sample runs of the program are shown below. Note: If the word is an odd number of letters, the first half should contain fewer letters (as shown in sample run #2) SAMPLE PROGRAM RUN #1                     Enter a word: carrot First half: car Second half: rot SAMPLE PROGRAM...
Write a program named CheckMonth2 that prompts a user to enter a birth month and day....
Write a program named CheckMonth2 that prompts a user to enter a birth month and day. Display an error message that says Invalid date if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February). If the month and day are valid, display them with a message. For example, if the month entered is 2, and the day...
(PYTHON) Lottery program. The program randomly generates a two-digit number, prompts the user to enter a...
(PYTHON) Lottery program. The program randomly generates a two-digit number, prompts the user to enter a single two- digit number, and determines whether the user wins according to the following rules. Write a loop to let the user play as many times as the user wanted. Use a sentinel or flag to quit out of the loop. 1.if the user’s input matches the lottery In the exact order, the award is $10,000. 2.if all the digits in the user’s input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT