Write a method whatSeason(month, day) that prints out the season according to the month and day.
The month is a integer that is one of the months - like 1 to 12.
The day is an integer that is a legal day of the month - like 1 to 31.
You may assume that the month and day are “legal” values.
Winter is from 12/21 to 3/19 Spring is from 3/20 to 6/20 Summer is from 6/21 to 9/22 Fall is from 9/23 to 12/20
It should print out one of these four messages:
It is spring.
It is summer.
It is fall.
It is winter.
month = input("Input the month (e.g. January, February etc.): ")
day = int(input("Input the day: "))
if month in ('January', 'February', 'March'):
season = 'winter'
elif month in ('April', 'May', 'June'):
season = 'spring'
elif month in ('July', 'August', 'September'):
season = 'summer'
else:
season = 'fall'
if (month == 'March') and (day > 19):
season = 'spring'
elif (month == 'June') and (day > 20):
season = 'summer'
elif (month == 'September') and (day > 21):
season = 'autumn'
elif (month == 'December') and (day > 20):
season = 'winter'
print("Season is",season)
Comments
Leave a comment