티스토리 뷰

python lecture/algorism

[edu] Seasons

burningrizen 2018. 11. 6. 11:53

Determine the season for a given date. You may assume that the start and end of each season is fixed to the dates given in the table below.

seasonstart dateend date
spring21 March20 June
summer21 June22 September
autumn23 September20 December
winter21 December20 March

Input

The day dN (1d31) and the name of the month for a given date, each on a separate line.

Output

A sentence that describes the season at the given date. Use

It is season on month day.

as a template for the description, where fragments in italics have to be filled up based on given and computed information.

Example

Input:

15
March

Output:

It is winter on March 15.

Epilogue

There's no mistaking a portrait by Giuseppe Arcimboldo (1527-1593) — the Milanese painter represented his subjects as masses of flowers, vegetables, fruits, and fish. These personifications of the four seasons were composed between 1563 and 1573.

the four seasons

Three years after personifying the four seasons, Giuseppe Arcimboldo did the same for the four elements.

the four elements

Around 1590 he also painted this Testa con cestino di frutta reversibile (Head with reversible fruit basket).

head with reversible fruit basket











def get_season(day, month):
if month == "March" and day >= 21 or month == "April" and day <= 30 or month == "May" or month == "June" and day <= 20:
season = "spring"
elif month == "June" and 21 <= day <= 30 or month == "July" or month == "August" or day <= 22 and month == "September":
season = "summer"
elif month == "September" and 23 <= day <= 30 or month == "October" or day <= 30 and month == "November" or day <= 20 and month == "December":
season = "autumn"
else:
season = "winter"
print("It is {} on {} {}.".format(season, month, str(day)))


get_season(int(input()), str(input()))


'python lecture > algorism' 카테고리의 다른 글

[edu] 수 찾기  (0) 2018.11.21
[edu] 가장 좋아하는 수 구하기  (0) 2018.11.21
[edu] Isomers  (0) 2018.11.04
[edu] Applied chemistry  (0) 2018.11.02
[edu] Friday the 13th  (0) 2018.10.24
댓글