Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Is Leap Year

Determine whether a given year is a leap year following Gregorian rules.

Python practice14 minControl Flow (If–Else Logic)IntermediateLast updated March 15, 2026

Problem statement

A year is a leap year if it is divisible by 4. However, years divisible by 100 are not leap years unless they are also divisible by 400. Implement is_leap_year(year) that applies these rules and returns True for leap years and False otherwise.

Task

Write a function that returns True if a year is a leap year and False otherwise, using if/elif/else logic.

Examples

Year 2000 is a leap year

Input

2000

Output

True

2000 is divisible by 400, so it's a leap year.

Input format

A single integer representing the year (e.g., 2024).

Output format

Return True if the year is a leap year, otherwise return False.

Constraints

Year is an integer. You may assume typical historical year ranges (positive and negative integers allowed), but apply the divisibility rules strictly.

Samples

Sample 1

Input

1900

Output

False

1900 is divisible by 100 but not by 400, so it's not a leap year.