In this tutorial we learn how to check leap year using Python 3.X program. Leap years are years where an extra day is added to the end of the shortest month (February). This additional day is added in February which makes it 29 days long.
Leap years have 366 days instead of the usual 365 days and occur almost every four years.
#function checkLeap will leap year def checkLeap(yr): if((Year % 400 == 0) or (Year % 100 != 0) and (Year % 4 == 0)): print("Leap Year"); else: print ("Not a leap Year") # Taking an input year from user yr= int(input("Enter the Year: ")) #Printing result checkLeap(yr)
Save above code as chekhleap.py. Open CMD or Terminal and run command given below
For Windows : python ./chekhleap.py
For Linux : python3 ./chekhleap.py