Python program to check leap year

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

If you like my post please share it with your friends by simply clicking the below social media button, and Don’t forget to comment so we will update ourselves.

Share in a Single Click

Leave a Reply

Your email address will not be published. Required fields are marked *