Python Program:Check Leap Year

What is Leap year:
A leap year is exactly divisible by 4 apart from century years (years ending with 00). The century year will be leap year if it is perfectly divisible by 400. For example,

2019 is not a leap year

1700 is a not leap year

2016 is a leap year

2000 is a leap year

Code for check leap year:

year = 2000

# To get year (integer) inputted by 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))

Output:

2000 is a leap year

Comments