Exercise · Operators · lesson 8 of 9
Exercise: leap year
Write a function is_leap(year) that returns True if the year is a leap year and False if it is not. A year is a leap year if one of these rules holds:
- the year is divisible by 4 but not by 100;
- the year is divisible by 400.
is_leap(2024)→Trueis_leap(1900)→Falseis_leap(2000)→True
Constraints: year is an integer from 1 to 9999. The tests check the answer with got is True or got is False: it demands exactly True or False, so the number 1 in place of True does not pass.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.