CASE SELECTON Example 1
(Mind the proper indentation, please arrange each line of code.)
# Using Python function and switch to implement CASE statement
def vowel(num):
switch={
1:'a',
2:'e',
3:'i',
4:'o',
5:'u'
}
return switch.get(num,"Invalid input")
print("What is your choice ?\n from 1 to 5")
num = input()
print ("You have chosen", num, "and it is", vowel(int(num)))
CASE SELECTON Example 2
(Mind the proper indentation, please arrange each line of code.)
import os #This import os, is a built-in function to allow the os.system('clear') to work.
def select(num):
switch={
1: "Cash Register",
2: "Monthly Report",
3: "Menu of the day",
4: "Exit"
}
return switch.get(num,"Please try again")
num=int(0)
while int(num) < 4:
print("\n\n\n")
print ("Please enter a choice \n 1: Cash Register \n 2: Monthly Report \n 3: Menu of the day \n 4: Exit")
num = input ()
print("\n")
print(" You have chosen ", num, " as the ", select(int(num)))
input()
os.system('clear')
print("You have exited")