Python Program to check whether the Year is Leap Year
check leap year Python
A leap year is a year that is evenly divisible by 4, except for end-of-century years, which must also be divisible by 400. This means:
In this article, we will write a Python program to determine whether a given year is a leap year or not.
def is_leap_year(year):
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print(year, "is a leap year")
else:
print(year, "is not a leap year")
# Taking user input
year = int(input("Enter the year: "))
is_leap_year(year)
is_leap_year(year)
checks if the year is divisible by 4 but not by 100, or if it is divisible by 400.input()
function allows the user to enter a year.Enter the year: 2000
2000 is a leap year
Enter the year: 1600
1600 is a leap year
Enter the year: 2020
2020 is a leap year
Enter the year: 2019
2019 is not a leap year
Checking for a leap year in Python is simple and efficient using modulus operations. This program can be extended for date-based calculations in real-world applications.