Python leap year program

Spread the love

In this tutorial you will learn how to write code for Python leap year program.

print("Leap year program") # Take input from the user year = int(input("Enter year ")) # 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))  

 

 

Output 1:

Leap year program

Enter year 2018
2018 is not a leap year

Output 2:

Leap year program

Enter year 2000
2000 is a leap year

admin

admin

Leave a Reply

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