We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ed0b64 commit d12fd4aCopy full SHA for d12fd4a
Arrays/Leap_Year.py
@@ -0,0 +1,34 @@
1
+'''
2
+Aim: To check if the entered year is a leap year or not.
3
+
4
5
6
+def is_leap(year):
7
+ # a year is a leap one if it's divisible by 4 and if it's not
8
+ # divisible by 100 or is divisible by 400
9
+ print((year%4==0 and (year%100!=0 or year%400==0)))
10
11
+# getting the input
12
+year = int(input().strip())
13
+# displaying the result
14
+is_leap(year)
15
16
17
18
+COMPLEXITY:
19
20
+ Time Complexity -> O(1)
21
+ Space Complexity -> O(1)
22
23
+Sample Input:
24
+2000
25
26
+Sample Output:
27
+True
28
29
+Explanation:
30
+2000 % 400 = 0
31
+2000 % 4 = 0
32
+Hence, 2000 was a leap year.
33
34
0 commit comments