Hey guys, in this blog we will see a Leap Year Program in Python.
Code
# Leap Year Program in Python
year = input('Input the year -> ')
year = int(year)
# divided by 100 means century year (ending with 00)
# century year divided by 400 is leap year
if (year % 400 == 0) and (year % 100 == 0):
print("{0} is a leap year".format(year))
# not divided by 100 means not a century year
# year divided by 4 is a leap year
elif (year % 4 ==0) and (year % 100 != 0):
print("{0} is a leap year".format(year))
# if not divided by both 400 (century year) and 4 (not century year)
# year is not leap year
else:
print("{0} is not a leap year".format(year))
Output
Input the year -> 2024 2024 is a leap year
Input the year -> 2023 2023 is not a leap year
Input the year -> 2021 2021 is not a leap year
So here we are checking 2 conditions for a year to be a leap year:
- Either It should be fully divisible by 400 and 100 both to be a Leap Year.
- Or it should be fully divisible by 4 and not by 100 then also it is a Leap Year.
- Else it’s not a Leap Year.
So this is how we can check if a year is a Leap Year or not.
Check out our other python programming examples…


![[Latest] Python for Loops with Examples – Easiest Tutorial – 2025](https://machinelearningprojects.net/wp-content/uploads/2023/05/python-for-loops-1-1024x536.webp)


