-
Notifications
You must be signed in to change notification settings - Fork 0
/
days_in_month.py
34 lines (28 loc) · 930 Bytes
/
days_in_month.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 1. take month and year input from user
# 2. if month is february, check if year is leap year(29) or not(28)
# 3. else: get the days from db and display the result
def is_leap_year(year):
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
else:
return True
else:
return False
def no_of_days(month, year):
if month == "feb":
if is_leap_year(year):
return 29
else:
return 28
else:
if month == "jan" or month == "mar" or month == "may" or month == "jul" or month == "aug" or month == "oct" or month == "dec":
return 31
else:
return 30
month = input("please enter the month: ")[0:3].lower()
year = int(input("please enter the year: "))
print(no_of_days(month, year))