-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzybooks 3.12 LAB Seasons.py
More file actions
128 lines (96 loc) · 2.81 KB
/
Copy pathzybooks 3.12 LAB Seasons.py
File metadata and controls
128 lines (96 loc) · 2.81 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# zybooks 3.12 LAB Seasons
# Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day.
# Ex: If the input is:
# April
# 11
# the output is:
# Spring
# In addition, check if the string and int are valid (an actual month and day).
# Ex: If the input is:
# Blue
# 65
# the output is:
# Invalid
# The dates for each season are:
# Spring: March 20 - June 20
# Summer: June 21 - September 21
# Autumn: September 22 - December 20
# Winter: December 21 - March 19
# LAB ACTIVITY 3.12.1: LAB: Seasons
# ================================================================== #
# original zybooks code
# input_month = input()
# input_day = int(input())
# ''' Type your code here. '''
# ================================================================== #
# code has passed all zybooks tests
input_month = input()
input_day = int(input())
months = ('January', 'February', 'March', 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , "October" , "November" , "December")
if not(input_month in months):
print('Invalid')
elif input_month in('March'):
if not(1 <= input_day <= 31):
print ('Invalid')
elif input_day <= 19:
print('Winter')
else:
print ('Spring')
elif input_month in ('April') :
if not(1 <= input_day <= 30):
print('Invalid')
else:
print('Spring')
elif input_month in ('May'):
if not(1 <= input_day <= 31):
print('Invalid')
else:
print('Spring')
elif input_month in ('June'):
if not(1 <= input_day <= 30):
print('Invalid')
elif input_day <= 20:
print ('Spring')
else:
print('Summer')
elif input_month in ('July', 'August'):
if not(1 <= input_day <= 31):
print('Invalid')
else:
print('Summer')
elif input_month in ('September'):
if not(1 <= input_day <= 30):
print('Invalid')
elif input_day <= 21:
print ('Summer')
else:
print ('Autumn')
elif input_month in ('October'):
if not(1 <= input_day <= 31):
print('Invalid')
else:
print('Autumn')
elif input_month in ('November'):
if not(1 <= input_day <= 30):
print('Invalid')
else:
print ('Autumn')
elif input_month in ('December'):
if not(1 <= input_day <= 31):
print('Invalid')
elif input_day <= 20:
print ('Autumn')
else:
print ('Winter')
elif input_month in ('January'):
if not(1 <= input_day <= 31):
print('Invalid')
else:
print('Winter')
elif input_month in ('February'):
if not(1 <= input_day <= 29):
print('Invalid')
else:
print ('Winter')
# ================================================================== #
# ================================================================== #