Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyMenuClass2
#python 3.6.9 #PyMenuClass2: example of use of dictionary instead of switch in PyMenuClass program #this code is created by Rezaul Hoque on May 06,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): print(f'Default package has 2 parathas, 1 scrambled egg and 1 chai. It costs Tk 50.\n') def pack_1(self): print(f'Package 1 has 2 rotis, 1 dal and 1 coffee. It costs Tk 80.\n') def pack_2(self): print(f'Package 2 has 3 slices of bread, jelly, banana and chai. It costs Tk 40.\n') def pack_3(self): print(f'Package 3 has 1 plate of khichri.It costs Tk 60.\n') if __name__=='__main__': t=Menu() MenuPick={0:t.pack_0, 1: t.pack_1, 2: t.pack_2, 3: t.pack_3} print("(0)Set Menu (1)Pack1(2)Pack2 (3)Pack3 (4)Quit") for choice in range(0,4): choice=int(input("Select: \n")) if(choice >= 0) and (choice <4): MenuPick[choice]()
run
|
edit
|
history
|
help
0
shuru11
hw11
Monthly Calendar
haha
Prime Factorization of a Number
Infinite Fibonacci generator
kawaii
Calendar 12 months
Restaurant 1
Helloworld