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' : ['h','c','f','p','m'],
'item' : ['hamburger', 'cheeseburger', 'fries', 'pepsi', 'milkshake'],
'cost' : [.4,.5,.3,.3,1],
'remain' : [100,50,200,200,25]
}
# create the dataframe from our dictionary
df = pd.DataFrame(data=inventory, index=inventory['code'], columns =['item', 'cost','remain'])
def order(df):
menu_item = True
total_cost =0.0
this_order =[]
while menu_item == True:
# print the menu and short keys
print(df[df['remain']>0])
# take in a code as an order
menu_item = input("Select 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
order(df)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!