Kodewick
Start learning →
Mini challenge←→0 / 100

Leap year?

#012Mini challengeConditionsNumbers6 min

The calendar needs to know how long February is. A leap year divides by 4 but not by 100, or divides by 400. Write is_leap(year) to return True for a leap year.

Examples
is_leap(2024)→True
is_leap(2023)→False
is_leap(1900)→False
main.py
def is_leap(year):
    by4 = year % 4 == 0
    by100 = year % 100 == 0
    by400 = year % 400 == 0
    # your code here: combine the three with and / or / not
    pass
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.