# Python program to check if year is a leap year or not
year = 2004
# To get year (integer input) from the user
# year = int(input("Enter a 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))
# Python program to check leap year or not
def checkYear(year):
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
return True
else:
return False
else:
return True
else:
return False
# Driver Code
year = 2000
if(checkYear(year)):
print("Leap Year")
else:
print("Not a Leap Year")
y = int(input())
if (y % 400 == 0) or (y % 100 != 0 and y %4 == 0):
print(y,"is leap year.")
else:
print(y,"isn't leap year.")
# Use calendar.isleap(year)
# https://docs.python.org/3/library/calendar.html#calendar.isleap has more information
import calendar
is_leap = calendar.isleap(2100) # returns False