File tree 3 files changed +37
-0
lines changed
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
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 ))
Original file line number Diff line number Diff line change
1
+ import calendar
2
+
3
+ print (calendar .isleap (1996 ))
4
+ print (calendar .isleap (2100 ))
5
+ print (calendar .isleap (2000 ))
You can’t perform that action at this time.
0 commit comments