Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary, day and we add it to the shortest month of the year, February.
In the Gregorian calendar three criteria must be taken into account to identify leap years:
This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.SourceTask
You are given the year, and you have to write a function to check if the year is leap or not.Note that you have to complete the function and remaining code is given as template.Input FormatRead y, the year that needs to be checked.ConstraintsOutput FormatOutput is taken care of by the template. Your function must return a boolean value (True/False)Sample Input
1990
Sample Output
False
Explanation1990 is not a multiple of 4 hence it’s not a leap year.
def is_leap(year):
leap = False
# Write your logic here
if year%4==0:
if year%100==0:
if year%400==0:
leap=True
else:
leap=False
else:
leap=True
else:
leap=False
return leap
year = int(input())
print(is_leap(year))
In our experience, we suggest you solve this Write a function Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Write a function problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Write a function Hacker Rank Solution
I hope this Write a function Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning Programming in a business context; there are no prerequisites.
Keep Learning!
More Hacker Rank Problem & Solutions >>
Staircase Hacker Rank Solution
A Very Big Sum Hacker Rank Solution
Diagonal Difference Hacker Rank Solution