For this assignment, you will create a calendar program that allows the user
to enter a day, month, and year in three separate variables as shown below.
Day:
Month:
Year:
Then, your program should ask the user to select from a menu of choices
using this formatting
Menu:
1) Calculate the number of days in the given month.
2) calculate the number of days left in the given year.

I would really appreciate it if someone could help me on this.

For This Assignment, You Will Create A Calendar Program That Allows The Userto Enter A Day, Month, And

Answers

Answer 1

Following are the program to the given question:

Program Explanation:

Defining three methods "leap_year, number_of_days, and days_left " is declared. In the "leap_year" method, it accepts the year variable, which calculates the year is the leap year and returns its value that is 1. In the next method "number_of_days", it is define which accepts the "year and month" variable in the parameter and calculate and returns its value. In the last "days_left" method, it calculates the left days and returns its value, and outside the method, two dictionary variable days_31 and days_30 is declared.  It initilized a value by using 3 input variable "day, month, and year" variable which accepts user-input value. In the next step, a "c" variable is declared, that input values and calls and print its value accordingly.

Program:

def leap_year(y):#defining a method leap_year that takes one parameter

   l= 0#defining l variable that holds an integer

   if y % 4 == 0:#using if block that check year value module by 4 equal to 0

       l = 1#holding value in l variable

   if y % 100 == 0:#using if block that check year value module by 100 equal to 0

       l = 0#holding value in l variable

       if y % 400 == 0:#using if block that check year value module by 400 equal to 0

           l= 1#holding value in l variable

   return l#return l value

def number_of_days(m, y):#defining a method number_of_days that takes two parameters

   months = {1: 31, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}#defining months variable that hold value in ictionary

   l = leap_year(y)#defining l variable that calls leap_year method and holds its value

   if l == 1 and m == 2:#use if that check l value equal to 1 and 2

       return 29#return value 29

   if m == 2:#use if that check month value equal to 2

       return 28#return value 29

   return months[m]#return months value

def days_left(d, m, y):#defining a method days_left that takes three variable in parameter

   l = leap_year(y)#defining l variable that hold leap_year method value

   days = 0#defining days variable that hold integer value

   months = {1: 31, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}#defining months variable that hold value in ictionary

   if l== 1:#using if that check l equal to 1

       if m > 2:#defining if that check m value greater than 2

           days += (29 + 31)#using days variable that Calculate holds its value

           i = m#defining i variable that holds months value

           while i > 2:#defining while loop that checks other days

               days += months[i]#defining a days variable that holds months value

               i -= 1#decreasing i value

           days -= (months[m] - d)#defining days that subtracts leap value

       elif m == 2:#defining elif block that checks m equal to 2

           days += (29 - d) + 31#holding value in days variable

       else:#defining else block

           days = 31 - d#Calculating days value

       return 366 - days#using return keyword that Calculates days value

   else:#defining else block

       if m > 2:#using if that checks m value greater than 2

           days += (28 + 31)#Calculating and store value in days

           i = m#holding months value in i

           while i > 2:#defining while loop that checks i value greater than 2

               days += months[i]#holding list value in days

               i -= 1#decreasing i value

           days -= (months[m] - d)#defining days that subtracts leap value

       elif m == 2:#using elif block that checks m value equal to 2

           days += (28 - d) + 31#Calculating and store value in days

       else:#defining else block

           days = 31 - d##Calculating and store value in days

       return 365 - days#return total days

print("Please enter a date")#print message

day = int(input("Day: "))#input value

month = int(input("Month: "))#input value

year = int(input("Year: "))#input value

print("Menu: ")#print message

print("1) Calculate the number of days in the given month.")#print message

print("2) Calculate the number of days left in the given year.")#print message

c = int(input())#input value

if c == 1:#using if that checks c value equal to 1

   print(number_of_days(month, year))#calling method and print its return value

elif c == 2:#using if that checks c value equal to 2

   print(days_left(day, month, year))#calling method and print its return value

Output:

Please find the attached file.

Learn more:

brainly.com/question/16728668


Related Questions

Other Questions
If 7^9/7^n = 7^3, then n is___.1201-33 Tell me a fun fact about horses will give BRAINLIEST to whoever tells me something I dont know (I have been riding for 12 years) so I know a lot of things (also dont tell me they can sleep standing up I already know that its kinda obvious) Why is GNI per capita a better measure of standard of living than GDP? A. GNI per capita reflects all of the income within the economy. B. GNI per capita indicates how much each person makes on average. C. GNI per capita represents the value of goods and services in the economy. D. GNI per capita reflects the total market value of goods and services in the economy. Please help me, i have an essay and its due tomorrow. Basically i have to write a blurb (the summary of the book in the back text). it needs to be 150 words, so please be creative. Dont copy it from google. Thanks so much it really means alot, this will affect my apply to college. BRAINLIEST! Please help me answer the following questions:1) How do you find the valency of an element?2) How do you determine if an element is nuetral/an isotope/ or an ion?If you could help with 1 or both questions I would really appreciate it :) that delivers oxygen to your body and In the video your blood is compared to a picks up CO2 to be released out when you breath. PLEASE I NEED A ANSWER The function y=2x+6 is shifted down 8 units. What is the equation of the new function? What does this image represent? Amine group Carbonyl group Ether group Hydroxyl group pls help find the inequality represented by the graph 1)Who built the pyramids?2)Who controlled the surplus of food in Egypt?3)Why was society divided into classes in the ancient river civilizations?4)How did trade and commerce affect civilization?5)Who were the Aryans? How do we know about them?6)What caused the decline of the original Indus Valley cultures?7)How do we know about the Ancient Israelites? What things and people were important tothem?8)What are the three different types of maps? What are their purposes? what is the main difference between a search bar and a web browser Please help please help 4.5/w = 3 what is the W? Federal district courts do not try military cases, claims brought against the U.S. government, or tax disputes between citizens and thegovernment becauseO A. they cannot be expected to rule impartially on cases involving the governmentB.original jurisdiction for such cases belongsthe Supreme CourtO C.such cases are tried only in state courtsODCongress has created specialized courts to deal with such cases Confused and I need help please PlS HELP QUICKLY :One of the roots of the equation x2bx+c=0 is equal to 5. Find c in terms of b.:Guys pls help and find what C is equal to. please help me for a question Subtract: 3.8 - 2.923. Explain in your own words how you would solve this, in detail, from start to finish. PLEASE HELP !! BRAINLIEST AND 10 POINTS Which of the following is an example of human systems in the Amazon? A Boating on the Amazon River B Speaking Portuguese C The Amazon's exact location D A waterfall on the Amazon River