Write a Python program to determine whether a given year is a leap year


This program checks whether a given year is a leap year or not. It does so by first prompting the user to enter a year using the input() function and then converts it to an integer using int().

The calendar.isleap() function of the calendar module is used to determine if the entered year is a leap year or not. It returns True if the given year is a leap year, and False if it is not. Finally, the function prints the result of calendar.isleap(y) to the console, where y is the year entered by the user.

Source Code

"""
#First Method
def check_leap_year(y):
    if y % 400 == 0:
        return True
    if y % 100 == 0:
        return False
    if y % 4 == 0:
        return True
    else:
        return False
 
y = int(input("Enter the Year :"))
print(check_leap_year(y))
"""
#Second Method
import calendar
def check_leap_year():
	y = int(input("Enter the Year :"))
	print(calendar.isleap(y))
check_leap_year()

Output

Enter the Year :2000
True

Example Programs