Smart Alarm
Programming Basics · Python
TASK
Problem
Given weekday `day` and vacation flag 0/1. Alarm is 7:00 on weekdays, 9:00 on weekends, and 10:00 on vacation.
EXAMPLE
Example
6 0
9:00
LIMITS
Constraints
1 ≤ day ≤ 7; vacation ∈ {0,1}
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `split()` separates one input line into individual values using spaces. `map()` applies the specified conversion to each input value. 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 `'10:00'` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Vacation has highest priority.']
ANSWER
Solution
+
d, v = map(int, input().split())
if v == 1:
print('10:00')
elif d >= 6:
print('9:00')
else:
print('7:00')