Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyMenuClass
#python 3.6.9 #PyMenuClass: example of switch using class #this code is created by Rezaul Hoque on April 10,2022. #contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; class Menu(object): def pack_0(self): s1=f'Default package has 2 parathas, 1 scrambled egg and 1 chai. It costs Tk 50.\n' return s1 def pack_1(self): s2=f'Package 1 has 2 rotis, 1 dal and 1 coffee. It costs Tk 80.\n' return s2 def pack_2(self): s3=f'Package 2 has 3 slices of bread, jelly, banana and chai. It costs Tk 40.\n' return s3 def pack_3(self): s4=f'Package 3 has 1 plate of khichri.It costs Tk 60.\n' return s4 def getMethod(self,op): calmethod="pack_"+str(op) method=getattr(self,calmethod,lambda :'Insert number between 0 and 4') return method() t=Menu() print(" (0)Set Menu (1)Pack1 (2)Pack2 (3)Pack3") choice=int(input("Select\n")) print(t.getMethod(choice))
run
|
edit
|
history
|
help
0
library
Calender 2019
Python
Faiha - Lesson 8
Lab_I_2_25_11_2020
Lawrence.py
test1
filtering python3
Pattern(L).py
Distribucion de cortes