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.
""" #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()
Enter the Year :2000 True
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions