Professional Documents
Culture Documents
5th Day of Python
5th Day of Python
case _ if x%2==0:
print(x, "the number is even")
case _:
print(x, "The number is odd")
___________________________________________________________________________________
___________________
Implement a function called get_day_of_week that
takes an integer representing the day of the week
(1 for Monday, 2 for Tuesday, ..., 7 for Sunday)
and returns the corresponding name of the day.
Use the match statement to accomplish this task.
___________________________________________________________________________________
___________________
def get_day_of_week(day_number):
match day_number:
case 1:
print("Monday")
case 2:
print("Tuesday")
case 3:
print("Wednesday")
case 4:
print("Thursday")
case 5:
print("Friday")
case 6:
print("Saturday")
case 7:
print("Sunday")
case _:
print("Invalid day number")