Python Lab Seasons

preview_player
Показать описание
3.12 LAB: Seasons
Python
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.
Рекомендации по теме
Комментарии
Автор

input_month = input()
input_day = int(input())

# check if input_month in list is valid
if input_month not in ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']:
print('Invalid')
# check if input_day is within calendar day range
else:
if (input_day >=31) or (input_day <=0):
print('Invalid')
# check if inputs for month and day are in season
elif (input_month in ['March'] and input_day >=20) or (input_month == 'April') or (input_month == 'May') or (input_month == 'June' and input_day <= 20):
print('Spring')
elif (input_month in ['June'] and input_day >= 21) or (input_month == 'July') or (input_month == 'August') or (input_month == 'September' and input_day <= 21):
print('Summer')
elif (input_month in ['September'] and input_day >=22) or (input_month == 'November') or (input_month == 'October') or (input_month == 'December' and input_day <=20):
print('Autumn')
elif (input_month in ['December'] and input_day >= 21) or (input_month == 'January') or (input_month == 'February') or (input_month == 'March' and input_day <=19):
print('Winter')

JHendo