Question: In python, take in a code as an order, check if the code is valid, check if the item is still in stock, remove one
In python, take in a code as an order, check if the code is valid, check if the item is still in stock, remove one item from the inventory, add the cost of the item to to the total bill and return the order and total cost.
Given code:
import pandas as pd
# create a dictionary of our menu items, including a short code, the item name, the cost, and the number remaining in stock.
inventory 'code' : hcfpm
'item' : hamburger 'cheeseburger', 'fries', 'pepsi', 'milkshake'
'cost' :
'remain' :
# create the dataframe from our dictionary
df pdDataFramedatainventory, indexinventorycode columns item 'cost','remain'
def orderdf:
menuitem True
totalcost
thisorder
while menuitem True:
# print the menu and short keys
printdfdfremain
# take in a code as an order
menuitem inputSelect from the menu Enter to be done
# check if the code is valid
# check if the item is still in stock
# remove one item from the inventory
# add the cost of the item ot the total bill
# return the total cost and the order
return
orderdf
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
