Answered step by step
Verified Expert Solution
Question
1 Approved Answer
menu = { 1 : { name : 'espresso', price: 1 . 9 9 } , 2 : { name :
menu : name: 'espresso', "price": : name: 'coffee', "price": : name: 'cake', "price": : name: 'soup', "price": : name: 'sandwich', "price": def getordermenu: order epresso 'coffe', 'cake' while True: try: itemnumber intinputEnter item number or to finish: if itemnumber : break elif itemnumber in menu: order.appendmenu else: printPlease enter a number between and : except ValueError: printInvalid input. Please enter a number: return order def calculatesubtotalorder: Calculates the subtotal of the order.""" Calculates the subtotal of an order IMPLEMENT ME Add up the prices of all the items in the order and return the sum Args: order: list of dicts that contain an item name and price Returns: float The sum of the prices of the items in the order printCalculating bill subtotal... subtotal subtotal sumitem for item in order return roundsubtotal raise NotImplementedError def calculatetaxsubtotal: Calculates the tax of an order return subtotal IMPLEMENT ME Multiply the subtotal by and return the product rounded to two decimals. Args: subtotal: the price to get the tax of Returns: float The tax required of a given subtotal, which is rounded to two decimals. printCalculating tax from subtotal... tax floatsubtotal return roundtax raise NotImplementedError def summarizeorderorder: Summarizes the order itemnames itemespresso coffee, cake for items in order subtotal calculatesubtotalorder: tax calculatetax total round return itemnames, total IMPLEMENT ME Calculate the total subtotal tax and store it in a variable named total rounded to two decimals Store only the names of all the items in the order in a list called names Return names and total. Args: order: list of dicts that contain an item name and price Returns: tuple of names and total. The return statement should look like return names, total # This function is provided for you, and will print out the items in an order def printorderorder: printYou have ordered strlenorder items' items espresso 'coffee', 'cake' items item for item in order printitems return order # This function is provided for you, and will display the menu def displaymenumenu: print Menu" for selection in menu: printfselectionmenuselectionname : menuselectionprice : print # This function is provided for you, and will create an order by prompting the user to select menu items def takeorderorder: displaymenumenu order epsresso coffee, cake' count for i in range: item input strcountfrom to : count order.appendmenuintitem return order Here are some sample function calls to help you test your implementations. Feel free to change, uncomment, and add these as you wish. def main: menu : name: 'espresso', "price": : name: 'coffee', "price": : name: 'cake', "price": : name: 'soup', "price": : name: 'sandwich', "price": # subtotal calculatesubtotalorder # printSubtotal for the order is: strsubtotal # tax calculatetaxsubtotal # printTax for the order is: strtax # items, subtotal summarizeorderorder order takeordermenu printorderorder subtotal calculatesubtotalorder printSubtotal for the order is: strsubtotal tax calculatetaxsubtotal printTax for the order is: strtax items, total summarizeorderorder printOrder summary:", items printTotal for the order is: strtotal if namemain: main I chose the following menu items: espresso, coffee, and cake. Can you solve each section of the script using the items that I chose? Also, can you send screen shots of each section?
menu
: name: 'espresso',
"price":
: name: 'coffee',
"price":
: name: 'cake',
"price":
: name: 'soup',
"price":
: name: 'sandwich',
"price":
def getordermenu:
order epresso 'coffe', 'cake'
while True:
try:
itemnumber intinputEnter item number or to finish:
if itemnumber :
break
elif itemnumber in menu:
order.appendmenu
else:
printPlease enter a number between and :
except ValueError:
printInvalid input. Please enter a number:
return order
def calculatesubtotalorder:
Calculates the subtotal of the order."""
Calculates the subtotal of an order
IMPLEMENT ME
Add up the prices of all the items in the order and return the sum
Args:
order: list of dicts that contain an item name and price
Returns:
float The sum of the prices of the items in the order
printCalculating bill subtotal...
subtotal
subtotal sumitem for item in order
return roundsubtotal
raise NotImplementedError
def calculatetaxsubtotal:
Calculates the tax of an order
return subtotal
IMPLEMENT ME
Multiply the subtotal by and return the product rounded to two decimals.
Args:
subtotal: the price to get the tax of
Returns:
float The tax required of a given subtotal, which is rounded to two decimals.
printCalculating tax from subtotal...
tax floatsubtotal
return roundtax
raise NotImplementedError
def summarizeorderorder:
Summarizes the order
itemnames itemespresso coffee, cake for items in order
subtotal calculatesubtotalorder:
tax calculatetax
total round
return itemnames, total
IMPLEMENT ME
Calculate the total subtotal tax and store it in a variable named total rounded to two decimals
Store only the names of all the items in the order in a list called names
Return names and total.
Args:
order: list of dicts that contain an item name and price
Returns:
tuple of names and total. The return statement should look like
return names, total
# This function is provided for you, and will print out the items in an order
def printorderorder:
printYou have ordered strlenorder items'
items espresso 'coffee', 'cake'
items item for item in order
printitems
return order
# This function is provided for you, and will display the menu
def displaymenumenu:
print Menu"
for selection in menu:
printfselectionmenuselectionname : menuselectionprice :
print
# This function is provided for you, and will create an order by prompting the user to select menu items
def takeorderorder:
displaymenumenu
order epsresso coffee, cake'
count
for i in range:
item input strcountfrom to :
count
order.appendmenuintitem
return order
Here are some sample function calls to help you test your implementations.
Feel free to change, uncomment, and add these as you wish.
def main:
menu
: name: 'espresso',
"price":
: name: 'coffee',
"price":
: name: 'cake',
"price":
: name: 'soup',
"price":
: name: 'sandwich',
"price":
# subtotal calculatesubtotalorder
# printSubtotal for the order is: strsubtotal
# tax calculatetaxsubtotal
# printTax for the order is: strtax
# items, subtotal summarizeorderorder
order takeordermenu
printorderorder
subtotal calculatesubtotalorder
printSubtotal for the order is: strsubtotal
tax calculatetaxsubtotal
printTax for the order is: strtax
items, total summarizeorderorder
printOrder summary:", items
printTotal for the order is: strtotal
if namemain:
main
I chose the following menu items: espresso, coffee, and cake. Can you solve each section of the script using the items that I chose? Also, can you send screen shots of each section?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started