def orderFood():
menu = dict([(1,(3.25,"Pricot Cake")),(2,(5.00,"Apple Cake")),(3,(7.25,"Hawaiian Pizza"))])
orders = []
print "Can I take your order? We currently have the following:"
for k,v in menu.iteritems():
print "Menu item #:{0} Name:{1} Price:{2}".format(k,v[1],v[0])
print "Please input your order separated by spaces:"
order = raw_input().split()
order = map(int, order)
lastPrice = 0
for x in range(len(order)):
lastPrice = lastPrice + menu[order[x]][0]
print "Here's your receipt!"
for x in range(len(order)):
print "You ordered {0} for {1}".format(menu[order[x]][1],menu[order[x]][0])
print "The total comes in at {0}".format(lastPrice)
print "Thanks! Come again!"
Output:
Quote
>>> orderFood()
Can I take your order? We currently have the following:
Menu item #:1 Name:Pricot Cake Price:3.25
Menu item #:2 Name:Apple Cake Price:5.0
Menu item #:3 Name:Hawaiian Pizza Price:7.25
Please input your order separated by spaces:
1 2 3
Here's your receipt!
You ordered Pricot Cake for 3.25
You ordered Apple Cake for 5.0
You ordered Hawaiian Pizza for 7.25
The total comes in at 15.5
Thanks! Come again!
Can I take your order? We currently have the following:
Menu item #:1 Name:Pricot Cake Price:3.25
Menu item #:2 Name:Apple Cake Price:5.0
Menu item #:3 Name:Hawaiian Pizza Price:7.25
Please input your order separated by spaces:
1 2 3
Here's your receipt!
You ordered Pricot Cake for 3.25
You ordered Apple Cake for 5.0
You ordered Hawaiian Pizza for 7.25
The total comes in at 15.5
Thanks! Come again!

New Topic/Question
Reply





MultiQuote




|