-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask_11.py
More file actions
26 lines (21 loc) · 907 Bytes
/
Task_11.py
File metadata and controls
26 lines (21 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
2. Ask the user for the outside temperature with `input("Temperature in °C: ")`, convert it to `int`, and store it in `temp`.
3. Write an `if-elif-else` chain that prints:
* `"Hot day"` if `temp` is **30 or above**
* `"Warm day"` if `temp` is **between 20 and 29**
* `"Cool day"` otherwise
4. Ask the user for their age, convert it to `int`, and use a **conditional expression** to set `access_msg` to `"You can vote"` or `"You cannot vote yet"`. Print `access_msg`.
5. Run the script with several input combinations to see each branch in action.
"""
# 1. Conditional statements
temperature = input("Temperature in °C: ")
if int(temperature) >= 30:
print("Hot day")
elif int(temperature) > 19:
print("Warm day")
else:
print("Cold day")
# 2. Conditional expression
age = input("Age in years: ")
access_msg = "Can vote" if int(age) >= 18 else "Can't vote"
print(access_msg)