We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Three conditions are used to identify leap years:
The year can be evenly divided by 4, is a leap year,

ifyear%4==0:leap==True

Unless, the year can be evenly divided by 100, it is NOT a leap year,

ifyear%100==0:leap==False

Unless, the year is also evenly divisible by 400. Then it is a leap year.

ifyear%400==0:leap==True

EXAMPLE:

defis_leap(year):leap=False# Write your logic hereifyear%4==0:leap=Trueifyear%100==0:leap=Falseifyear%400==0:leap=Truereturnleapyear=int(input())print(is_leap(year))

## Write a function

You are viewing a single comment's thread. Return to all comments →

Three conditions are used to identify leap years: The year can be evenly divided by 4, is a leap year,

Unless, the year can be evenly divided by 100, it is NOT a leap year,

Unless, the year is also evenly divisible by 400. Then it is a leap year.

EXAMPLE: