BasicsChallenge 7 of 34

Leap years

Write is_leap(year). A year is a leap year if it is divisible by 4, except centuries, which are leap years only when divisible by 400. So 2000 and 2024 are leap years; 1900 and 2023 are not.

Exercise

Leap years

3 checks
def is_leap(year):
    ...


for y in [1900, 2000, 2023, 2024]:
    print(y, is_leap(y))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.