Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Problem No 13

Is Leap Year

Medium

14 minute session

Summary

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

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

Explanation

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 input 0

1900

Sample output 0

False

Explanation 0

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

Code editor
Loading editor…

AI assistant

Ask me anything!

Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.

Chat history is temporary and will not be saved.

03:50 AM

Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.