Leap year function

EasyFunction Programs · 31 of 39

Write a Python function to check whether a year is a leap year.

Advertisement
Input
2024, 2100
Output
True False

Approach

  1. Return the combined condition.

Solution

Python
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
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More function programs

← All 39 Function Programs