This Python program will demonstrate how you can check to see if a given year is a leap year or not.
A leap year is a year that is exactly divisible by 4 except for the years that end with 00. For the years that ends with 00 , it is considered to be a leap year if it is divisible by 400.
How to check if a given year is Leap Year in Python?
# Author : Abandantcode.com
# Python Program to Check if year is a leap year
inputYear = 2021
if (inputYear % 4) == 0:
if (inputYear % 100) == 0:
if (inputYear % 400) == 0:
print("{0} is a leap year".format(inputYear))
else:
print("{0} is not a leap year".format(inputYear))
else:
print("{0} is a leap year".format(inputYear))
else:
print("{0} is not a leap year".format(inputYear))Output
2021 is not a leap year
In the above program , we have used the input value as 2021. This year is not exactly divisible by 4 and hence it is not a leap year. Try 2000, you should see the output display as Leap Year.

Leave a Reply