Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: Write a Python function to check if a given year is a leap year.
Answer:

def is_leap_year(year):

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

Example:

is_leap_year(2024)  # Output: True
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook