-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif_elif_else.py
More file actions
31 lines (28 loc) · 1.32 KB
/
if_elif_else.py
File metadata and controls
31 lines (28 loc) · 1.32 KB
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
27
28
29
30
31
# A function is created with the def() keyword. The parameter
# variable "time_as_string" is passed to the function through a
# call to the function.
def task_reminder(time_as_string):
# The following if-elif-else block assigns various strings to
# the variable "task" depending on specific conditions. The
# test conditions are set using the == equality comparison
# operator. In this case, the time passed through the
# "time_as_string" parameter variable is tested as the
# specific condition. So, if the time is "11:30 a.m.", then
# "task" is assigned the value: "Run TPS report".
if time_as_string == "8:00 a.m.":
task = "Check overnight backup images"
elif time_as_string == "11:30 a.m.":
task = "Run TPS report"
elif time_as_string == "5:30 p.m.":
task = "Reboot servers"
# The else statement is a catchall for all other values of
# the "time_as_string" parameter variable not listed in the
# if-elif block of code.
else:
task = "Provide IT Support to employees"
# This line returns the value of "task" to the function call.
return task
# This line calls the function and passes a parameter
# ("10:00 a.m.") to the function.
print(task_reminder("10:00 a.m."))
# Should print "Provide IT Support to employees"