Switch statement in Python

If-Else statement
def Function_1():
return 'Function_1'
def Function_2():
return 'Function_2'
def Function_3():
return 'Function_3'
def Function_4():
return 'Function_4'
def Function_5():
return 'Function_5'
def Select_Function(p_choice):
p_fun_dict={1:Function_1(),
2:Function_2(),
3:Function_3(),
4:Function_4(),
5:Function_5()}
return p_fun_dict.get(p_choice)
p_fun_dict_out={1:Function_1(),
2:Function_2(),
3:Function_3(),
4:Function_4(),
5:Function_5()
}
from random import choiceprint(Select_Function(choice([1,5,2,4,3])))
print(p_fun_dict_out[choice([1,5,2,4,3])])

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store