Python program to tell if a given year is leap year or not
In this post, you will learn to check whether the given year is a leap year or not.
A year is considered as leap year if it is divisible by 4 or divisible by 400(for the years ending with 00).
Python program to check if a year is leap year
year=int(input("\n"))
if(year%4==0) :
if(year%100==0) :
if(year%400==0):
print("The given year", year,"is a leap year")
else:
print("The given year", year, "is not a leap year")
else:
print("The given year", year, "is a leap year")
else:
print("The given year", year, "is not a leap year")
Try yourself here by providing input year in the stdin
section.
Results
When you give input as 2000:
The given year 2000 is a leap year
When you give input as 2025:
The given year 2025 is not a leap year