easy +10 pts

Leap Year Checker

Determine if a given year is a leap year using the Gregorian calendar rules.

Write a function `is_leap_year(year: int) -> bool` that returns `True` if the given year is a leap year, `False` otherwise. A year is a leap year if it is divisible by 4, except that years divisible by 100 are not leap years, unless they are also divisible by 400. Examples: - 2020 is divisible by 4, not by 100 → leap year. - 1900 is divisible by 4 and by 100, but not by 400 → not a leap year. - 2000 is divisible by 400 → leap year. - 2023 is not divisible by 4 → not a leap year.

Constraints

- `year` is an integer between 1 and 10_000 inclusive. - The decision must follow the Gregorian calendar rule.

Example

>>> is_leap_year(2020)
True
>>> is_leap_year(1900)
False
>>> is_leap_year(2000)
True
>>> is_leap_year(2023)
False
10 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Check if the year is divisible by 4 first.
If the year is divisible by 100, it must also be divisible by 400 to be a leap year.
A boolean expression combining these conditions can be written in one line.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.