Answer to Question #293745 in Python for hsoxx01

Question #293745

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.
1
Expert's answer
2022-02-04T01:44:40-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS