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.