Leap Year by the Full Rules

Easy ⏱ 8 min 72% acceptance ★★★★★ 4.8
Write is_leap(year) implementing the complete Gregorian rule: divisible by 4, except century years, unless divisible by 400. 1900 → False, 2000 → True. (calendar.isleap exists; write the logic yourself here.)

Examples

Example 1
Input
is_leap(1900)
Output
False
Explanation

Century not divisible by 400.

Example 2
Input
is_leap(2000)
Output
True
Explanation

Divisible by 400.

Constraints

  • No calendar module.
  • One boolean expression preferred.

Topics

Date & Timeleap year

Companies

TCSWiproCognizant

Hints

Hint 1

(y % 4 == 0 and y % 100 != 0) or y % 400 == 0.

Hint 2

Test both example years.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.