-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathexercise_12.py
38 lines (35 loc) · 983 Bytes
/
exercise_12.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
35
36
37
38
def leapYear(year):
if (year % 4) != 0:
return False
else:
if (year % 100) == 0:
if (year % 400) ==0:
return True
else:
return False
else:
return True
def main():
dateStr = '6/29/1100'
monthStr, dayStr, yearStr = dateStr.split("/")
month = int(monthStr)
day = int(dayStr)
year = int(yearStr)
if month > 12 or day > 31:
print("This date is invalid.")
else:
if day <= 28:
print("This date is valid.")
elif month == 2 and day == 29:
if leapYear(year) == False:
print("This date is invalid.")
else:
print("This date is valid.")
elif day == 31:
if month == 2 or 4 or 6 or 11:
print("This date is invalid")
else:
print("This date is valid")
else:
print("The date is valid.")
main()