You will write three small functions about the calendar.
The idea. A year that divides by 4 is a leap year, but a century year is a leap year only if it divides by 400. In Python, year % 4 == 0 is True when the year divides by 4.
Your tasks.
is_leap, return True if year is a leap year and False if not.days_in_year, return 366 for a leap year and 365 for any other year.count_leap, return how many leap years there are from first to last, both included.Run your code once to unlock the worked solution.
Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…