Skip to content

Commit c543c0f

Browse files
committed
Day 12: find leap year
1 parent 84240bc commit c543c0f

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

daily_challenges/day_12/__init__.py

Whitespace-only changes.

daily_challenges/day_12/leap_year.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
********DAY 12********
3+
Python coding question:
4+
5+
Write a code to check whether a year is leap year or not.
6+
Note:A year that is evenly divisible by 100 is a leap year only if it is also evenly divisible by 400.
7+
8+
A leap year is exactly divisible by 4 except for century years (years ending with 00). The century year is a leap year
9+
only if it is perfectly divisible by 400.
10+
11+
12+
A year is a leap year if the following conditions are satisfied:
13+
14+
The year is multiple of 400.
15+
The year is multiple of 4 and not multiple of 100.
16+
17+
Desired Output:
18+
is_leap(1996)-->Leap year
19+
is_leap(2100)-->not a Leap year
20+
is_leap(2000)—>Leap year
21+
"""
22+
23+
24+
def leap_year(year):
25+
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
26+
return True
27+
return False
28+
29+
30+
print(leap_year(1996))
31+
print(leap_year(2100))
32+
print(leap_year(2000))

daily_challenges/day_12/practice.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import calendar
2+
3+
print(calendar.isleap(1996))
4+
print(calendar.isleap(2100))
5+
print(calendar.isleap(2000))

0 commit comments

Comments
 (0)