Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IMPORTANT: Do this lab using def next_holiday(year, month, day): and define no other functions. Use lists and if elif and else statments only. ONly use

IMPORTANT: Do this lab using def next_holiday(year, month, day): and define no other functions. Use lists and if elif and else statments only. ONly use loops if there is no other way around it. And do this using python 3.7 for windows please.image text in transcribedimage text in transcribed

Unitario tatutory Monuys anu ZUZU Dates Holiday Name new year's day Date* Jan 1 family day Feb 17 good friday Apr 10 victoria day May 18 canada day Jul 1 civic holiday Aug 3 labour day Sep 7 thanksgiving day Oct 12 christmas day Dec 25 boxing day Dec 26 * for simplicity assume Family Day, Good Friday, Victoria Day, Civic Holiday, Labour Day, and Thanksgiving day fall on these dates each year. Example Test Cases Inputs next_holiday (2019,1, 31) next_holiday (2019,13,3) next_holiday (2040,8,2) next_holiday (2022,2, 29) next_holiday (2021,9,19) next_holiday (2020,2,29) next_holiday (2008,12,25) next_holiday (2022, 12,28) Output ['family day', 17] I ['invalid month', -1] ['civic holiday', 1] T'invalid day', -1] ['thanksgiving day',23] ['good friday', 41] ["boxing day', 1] ["new year's day", 4] When you have completed and tested all the functions, submit it for grading on Markus. IMPORTANT: Do not change the file name or function names. Do not use input () or print() inside the functions. Five test cases are provided on Markus. You should test your code before your final submission. These test cases will be used in grading with an additional five test cases. Problem Your task for this lab is to complete the next_holiday (year, month, day) function. This function accepts three integer inputs representing a year, month, and a day and must return a two-element list containing a string with the name of the next Ontario statutory holiday and an integer representing the number of days until that holiday. The string with the name of the holiday should be all lower-case characters. The names of the holidays are given in the table below. To better understand the problem, consider the following example: >>> next_holiday (2020,2,3) In this case, the input represents the date February 3rd , 2020. The next statutory holiday after this date is Family day on February 17th. So for this input, our function would return the following list: ['family day', 14] The first element in the returned list is a string with the name of the holiday. Note that all the characters in the string are lower-case. The second element in the list is the number of days until Family day. To simplify the problem, we will assume that all holidays will fall on the same date each year and we will use the 2020 dates. A list of all the statutory holidays and their corresponding date's are given below. Your function should check for leap years and adjust results appropriately. A year is a leap year if it satisfies one of the following conditions: . The year can be evenly divided by 4 and can not be evenly divided by 100, OR The year is evenly divisible by 400. For example, 1996 is a leap year because it satisfies condition 1, 2009 is not a leap year because it satisfies neither condition, and 2000 is a leap year because it satisfies condition 2. If the function is passed an invalid entry for the month or the day, the program should return ['invalid month',-1] or ['invalid day',-1], respectively. If passed both an invalid month and an invalid day, the program should return ['invalid month',-1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Will there be psychology (or perhaps any science at all) in heaven?

Answered: 1 week ago