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:...
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
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...
Write a Python program using functions and mainline logic which prompts the user to enter a...
Write a Python program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a file. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The average number in the list At a minimum, the numbers should...
Write a PYTHON program that prompts the user to enter the account’s present value, yearly interest...
Write a PYTHON program that prompts the user to enter the account’s present value, yearly interest rate, and the number of years that the money will be left in the account. The program should pass these values to a function that returns the future value of the account, after the specified number of months. The program should display the accounts’ future value
In PYTHON OF JUPIDER NOTEBOOK Write a program that prompts the user to enter his/her nationality...
In PYTHON OF JUPIDER NOTEBOOK Write a program that prompts the user to enter his/her nationality (French/french, Italian/italian, or Spanish/spanish). Then ask his/her name using a prompt message in his/her own language (use Google Translate if you need). After getting the name, again greet him/her using a greeting message in his/her own language. If the user is not from any of the above nationalities just use English to prompt for name and to greet the user. Example 1: Nationality? french...
Write a C# program that prompts the user to enter in three values. The first indicates...
Write a C# program that prompts the user to enter in three values. The first indicates a starting (whole number positive) value, the second an ending value and the third an increase value. output a table of squares and square roots, every increase value from the start to the end value. For instance if the values were: start 3, end 20, and increase 4. the table would consist of 3,7,11,15,19 and their squares and square roots. Please include all code...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT