Season
Programming Basics · Python
TASK
Problem
Given month number, print `WINTER`, `SPRING`, `SUMMER`, or `AUTUMN`.
EXAMPLE
Example
9
AUTUMN
LIMITS
Constraints
1 ≤ month ≤ 12
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `int()` converts a numeric string into an integer. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `or` requires at least one condition to be true. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** An `if` statement chooses a program branch from a Boolean condition. Comparisons produce `True` or `False`, and `elif` lets you test several mutually exclusive cases in order. The expression `'WINTER'` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Winter is 12,1,2; spring 3–5; summer 6–8.']
ANSWER
Solution
+
m = int(input())
if m == 12 or m <= 2:
print('WINTER')
elif m <= 5:
print('SPRING')
elif m <= 8:
print('SUMMER')
else:
print('AUTUMN')