HW3a: Gregorian Leap Years (10 Points)
Due Monday 2/20/2023
Overview
Because the length of a tropical year is actually about 365.24 days, we occasionally need leap years with 366 days to keep everything on track. The Julian calendar originally had a simple rule that a leap year occurred every 4 years, but this led to too many leap years, so the modern Gregorian calendar has slightly different rules, which are as follows:
- Every year that is not a centennial year, but which is evenly divisible by 4, is a leap year.
- Only centennial years which are evenly divisible by 400 are leap years. So, for instance, the year 2000 was a leap year, and 2400 will be a leap year, but 1900 was not, nor will 2100, 2200, or 2300 be.
Code To Write
You should create a notebook with a method is_a_leap_year(year)
. This method should take as input a year, and it should return True
if that year is a leap year or False
otherwise. Submit this file to Canvas when you are finished.
Testing
Be sure to run your code on at least 4 cases that cover all of your code:
- A non-centennial year which is not a leap year (e.g. 1997)
- A non-centennial year which is a leap year (e.g. 2020)
- A centennial year which is not a leap year (e.g. 1900)
- A centennial year which is a leap year (e.g. 2400)