Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Just calculating it, without importing anything solution in Clear category for Leap Year Checking by Selindian
def is_leap_year(year: int) -> bool:
# Must be divisible by 4 but not divisible by 100 except if it's also divisible by 400.
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
print("Example:")
print(is_leap_year(1891))
# These "asserts" are used for self-checking
assert is_leap_year(2000) == True
assert is_leap_year(1900) == False
assert is_leap_year(2004) == True
assert is_leap_year(2100) == False
assert is_leap_year(2020) == True
assert is_leap_year(2021) == False
assert is_leap_year(1600) == True
assert is_leap_year(1700) == False
assert is_leap_year(1800) == False
assert is_leap_year(2400) == True
print("The mission is done! Click 'Check Solution' to earn rewards!")
May 27, 2024