Day of Week
Programming Basics · Python
TASK
Problem
Given weekday number 1..7, print the English day name.
EXAMPLE
Example
3
WEDNESDAY
LIMITS
Constraints
1 ≤ day ≤ 7
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`. `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 `'MONDAY'` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Map each number to its branch.']
ANSWER
Solution
+
d = int(input())
if d == 1:
print('MONDAY')
elif d == 2:
print('TUESDAY')
elif d == 3:
print('WEDNESDAY')
elif d == 4:
print('THURSDAY')
elif d == 5:
print('FRIDAY')
elif d == 6:
print('SATURDAY')
else:
print('SUNDAY')