Python program to check leap year
In this example, we will learn how to check whether a given year is a leap.
So first of all we have to know which year is a leap year
A leap year is perfectly divisible by 4 except a century year.
This means the year should not be divisible by 100 but a century year divisible by 400 is a Leap year.
#python program to check leap year
year = int( input(‘ Enter any year to check : ‘ ) )
if ( ( year % 4 == 0) & ( year % 100 !=0) ):
print(‘{0} is a Leap year’.format(year))
elif (Â year % 400 == 0 ):
print(‘{0} is a Leap year’.format(year))
else:
print(‘{0} is not a Leap year’.format(year))
Output
Enter any year to check : 1200
1200 is a Leap year
Again run the program
Enter any year to check : 500
500 is not a Leap year
Again run the program
Enter any year to check : 2020
1200 is a Leap year
Again run the program
Enter any year to check : 1996
1200 is a Leap year