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

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 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...
( USE C++ ) The program prompts the user to enter a word. The program then...
( USE C++ ) The program prompts the user to enter a word. The program then prints out the word with letters in backward order. For example, if the user enter "hello" then the program would print "olleh" show that it works .
jgrasp environment, java write a complete program that prompts the user to enter their first name,...
jgrasp environment, java write a complete program that prompts the user to enter their first name, middle name, and last name (separately). print out thier name and initials, exactly as shown: your name is: John Paul Chavez your initials are: J. P. C. use string method chartAt() to extract the first (zero-th) character from a name(the name is a string type): username.charAt(0). thank you.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT