Python Practice › Function Programs › Program 31
Leap year function
Write a Python function to check whether a year is a leap year.
Input
2024, 2100
Output
True False
Approach
- Return the combined condition.
Solution
def is_leap(year): return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) print(is_leap(2024), is_leap(2100))Output
True False
Learn the concept
New to this topic? Read the lesson, then come back.