Leap year
A leap year is a calendar year that includes an additional day to synchronize the calendar year with the astronomical or seasonal year. – Wikipedia
Logic
The Logic to check this is quite simple. We only need to check if the given year is multiple of 4 or 400, but it should not be multiple of 100.
Program
# Take year from user year = int(input("Enter a year : ")) # Check for leap year if year % 4 == 0 : if (year % 100 == 0) : if (year % 400 == 0) : print("\n" + str(year), "is a leap year.") else : print("\n" + str(year), "is not a leap year.") else : print("\n" + str(year), "is a leap year.") else : print("\n" + str(year), "is not a leap year.")
Output
Enter a year : 2012
2012 is a leap year.