CHECK FOR A LEAP YEAR IN PYTHON

See if the year is evenly divisible by 4 (a whole number with  no remainder). If it is not, like 1997, it  is not a leap year.  If it is,  like 2012  then see if the year is divisible  by100.  If a year is  divisible by 4, but not 100,  like 2012, it is a leap year. If a  year  is divisible  by  both 4 and 100,  like 2000 then  see if  the year is divisible  by 400. If a year is divisible by 4 and 100, but not 400,  like 1900,  then it is not a  leap year.  If a year is  divisible by all 4, 100  and  400, then  it is a  leap year. So  2000 is  indeed  a leap year.

Program

#Python program to check if the year is a leap year or not

# To get year (integer input) from the user

year = int(input(“Enter a year: “))

if (year % 4) == 0:

if (year % 100) == 0:

if (year % 400) == 0:

print(“{0} is a leap year”.format(year))

else:

print(“{0} is not a leap year”.format(year))

else:

print(“{0} is a leap year”.format(year))

else:

print(“{0} is not a leap year”.format(year))

input(“Press Enter to Exit”)