Skip to content

Commit

Permalink
edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Muna-S committed Jan 9, 2025
1 parent 55badc2 commit 2a54ed4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions solutions/leap_year.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
The module checks whether a given year is a leap year.
A year is a leap year if it is divisible by 4,
and if it is divisible by 100, it must also be divisible by 400.
"""

def leap_year(year: int) -> bool:
"""
Checks whether the given year is a leap year.
Argument:
year, a positive integer
Returns:
boolean: True if the year is a leap year, false otherwise.
Examples:
>>> leap_year(2024)
True
>>> leap_year(1900)
False
>>> leap_year(2021)
False
"""
if not isinstance(year, int):
raise ValueError("Year must be an integer")
if year < 0:
raise ValueError("Year must be positive integer")

return(year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)

0 comments on commit 2a54ed4

Please sign in to comment.