Skip to content

Commit d12fd4a

Browse files
authored
Add files via upload
1 parent 4ed0b64 commit d12fd4a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Arrays/Leap_Year.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)