Skip to content

Commit bd499d3

Browse files
author
Vimal A R
committed
HackerRank Python challenge - Leap year
1 parent 281c784 commit bd499d3

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

Day-109/leap_year.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,29 @@
33
# HackerRank Problem
44
# https://www.hackerrank.com/challenges/write-a-function/problem
55

6+
# Source: Wikipedia - https://en.wikipedia.org/wiki/Leap_year
7+
# The following pseudocode determines whether a year is a leap year or a common year
8+
# in the Gregorian calendar (and in the proleptic Gregorian calendar before 1582).
9+
# The year variable being tested is the integer representing the number of the year
10+
# in the Gregorian calendar.
611

7-
def is_leap(year):
8-
leap = False
12+
# if (year is not divisible by 4) then(it is a common year)
13+
# else if (year is not divisible by 100) then(it is a leap year)
14+
# else if (year is not divisible by 400) then(it is a common year)
15+
# else (it is a leap year)
916

1017

18+
def is_leap(year):
19+
leap = False
20+
if year % 4 != 0:
21+
pass
22+
elif year % 100 != 0:
23+
leap = True
24+
elif year % 400 != 0:
25+
leap = False
26+
else:
27+
leap = True
28+
print(leap)
1129
return leap
1230

13-
14-
year = int(input())
31+
is_leap(2000)

0 commit comments

Comments
 (0)