Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

Python Program to Check Leap Year

Python Program to Check Leap Year

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(Year):   
  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

Python leap year

5 3 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments