Posted inPython

How To Implement Leap Year Program in python?

Today, We want to share with you leap year program in python.In this post we will show you Python Program to Check Leap Year, hear for write a program to find the input year is leap or not in python we will give you demo and example for implement.In this post, we will learn about PHP Shorthand Ternary Operator Examples with an example.

Python Program to Check whether Year is a Leap Year or not

2017 is not a leap year
1900 is a not leap year
2012 is a leap year
2000 is a leap year

Source Code

Example 1:

# Python Example to check if year is a leap year or not

year = 2000

# To get year (integer input) from the user
# year = int(input("Give Any 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))

Results

2000 is a leap year

How to determine if a year is a leap year?

Example 2:

year = int(input("Give Any 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))  

I hope you get an idea about leap year program in python hackerrank solution.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype