Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Leap Year Logic

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Leap Year Logic. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Write the logic of a program to find whether a given year is a leap year or not.

Implement the function using the Gregorian calendar rules. Return True if the year is a leap year and False otherwise. A year is leap if it is divisible by 400, or divisible by 4 but not by 100.

Constraints

  • year is an integer
  • 1 <= year <= 10^9
  • Use Gregorian calendar leap-year rules

Function Signature

def is_leap_year(year):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output