Question: (python) A standard year in the Gregorian calendar is 365 days. To compensate for the fact that the Earths orbit is slightly longer, the calendar

(python)

A standard year in the Gregorian calendar is 365 days. To compensate for the fact that the Earths orbit is slightly longer, the calendar inserts one extra day, called the leap day, into some years. Such years, which are called leap years, have 366 days. You may think that every fourth year is a leap year, but that is not exactly true. Adding a leap day every fourth year is slightly too much. Therefore, the Gregorian calendar removes 3 leap days every 400 years. The exact rule for which years are leap years is: A year X is a leap year iff X is a multiple of 4 but not a multiple of 100, or if X is a multiple of 400. Your task is to write a function that computes the total number of days in a range of years. The function definition should be like this: def total_days(start_year, end_year): # ...your code here... The function should return the number of days from the 1st of January of start_year to (but not including) the 1st of January end_year. In other words, it should return the sum of the number of days in each year from start_year to, but not including, end_year.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!