Check Leap Year
Easy
60
80.1% Acceptance
In this lab, you are tasked with writing a Python function named is_leap_year
. This function should determine whether a given year is a leap year. A leap year is defined by the following rules:
- A year is a leap year if it is divisible by 4.
- However, if the year is also divisible by 100, it is not a leap year unless it is divisible by 400.
Your function should take a single input (the year) and return a boolean value: True
if the year is a leap year, and False
otherwise.
Examples:
-
Input:
is_leap_year(2000)
Expected Output:True
Explanation: 2000 is divisible by 400, so it is a leap year. -
Input:
is_leap_year(1997)
Expected Output:False
Explanation: 1997 is not divisible by 4, so it is not a leap year.
Remember to write clean, readable code and test your function thoroughly to ensure it meets the criteria.