subject

HELP!!! 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.

Your program must include the three following functions:
leap_year
number_of_days
days_left

Parameters:
leap_year(y)
number_of_days(m, y)
days_left(d, m, y)

This is the code I have so far but I'm still getting some errors:
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

can someone please help me out? I will mark whoever gives me the right code the brainliest!!!

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:20
Consider the following statements, then select one of the answers below: the signal() function shown below registers "sig_handler()" as the signal handler function for the sigkill signal, without the complexity of using when the sigkill signal is sent to a process running this code, by a user typing "kill -kill ", where the correct process id is used for to target the process, sig_handler() will be executed.
Answers: 1
question
Computers and Technology, 22.06.2019 22:40
Write a program that defines symbolic names for several string literals (chars between quotes). * use each symbolic name in a variable definition. * use of symbolic to compose the assembly code instruction set can perform vara = (vara - varb) + (varc - vard); ensure that variable is in unsigned integer data type. * you should also further enhance your symbolic logic block to to perform expression by introducing addition substitution rule. vara = (vara+varb) - (varc+vard). required: debug the disassembly code and note down the address and memory information.
Answers: 3
question
Computers and Technology, 23.06.2019 00:00
How do we use the sumif formula (when dealing with different formats) ?
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
Rafael needs to add a title row to a table that he has inserted in word. what should he do? use the alignment options. use the merge and center option for all the cells in the top row. use the merge and center option on the first two cells in the top row. none of the above
Answers: 3
You know the right answer?
HELP!!! For this assignment, you will create a calendar program that allows the user
to ente...
Questions
question
Mathematics, 07.06.2020 02:59
question
Spanish, 07.06.2020 02:59
Questions on the website: 13722361