Question: For this problem you should write the 3 functions described below. Later functions may need to call earlier functions so you should write the functions

For this problem you should write the 3 functions described below. Later functions may need to call earlier functions so you should write the functions in order. For example, calDayNum should at some point call validDate. 1. leapYear(year): A year is a leap year if it is divisible by 4, unless it is a century year (i.e. a year divisible by 100) that is not divisible by 400.(1800 and 1900 are not leap years while 1600 and 2000 are.) This Boolean function should return True if year is a leap year and False if it is not a leap year. 2. validDate (month, date, year): This Boolean function should return True if month/date/year is a valid date and False otherwise. For example 5/24/1962 is valid, but 9/31/2000 is not. (September has only 30 days.) Hint: This function should call your leapYear function. 3. calDayNum (month, date, year) : The days of the year are often numbered from 1 through 365(or 366 in a leap year). This is called the Day of Year Number. This function should first verify that month/date/year is a valid date and then return the corresponding day of year number (this should be an integer). If the month/date/year is not valid your function should return -1. You might find this website e helpful for testing your function. The day of year number can be computed in 3 steps. 1. set day_num= 31 * (month - 1) + day 2. if the month is after February subtract (4 * month + 23) / 10 3. if it's a leap year and after February 29, add 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
