In: Computer Science
Implement the following function in the PyDev module functions.py and test it from a PyDev module named :
def fast_food(): """ ------------------------------------------------------- Food order function. Asks user for their order and if they want a combo, and if necessary, what is the side order for the combo: Prices: Burger: $6.00 Wings: $8.00 Fries combo: add $1.50 Salad combo: add $2.00 Use: price = fast_food() ------------------------------------------------------- Returns: price - the price of one meal (float) ------------------------------------------------------- """
Sample testing:
Order B - burger or W - wings: B Make it a combo? (Y/N): N Price: $6.00 Order B - burger or W - wings: W Make it a combo? (Y/N): Y Add F - fries or S - salad: F Price: $9.50
Python code:
try:
def fast_food():
main_course = {"B": 6.00, "W": 8.00}
combo = {"F": 1.50, "S": 2.00}
print("Menu:\n\tBurger:\t$6.00\n\tWings:\t$8.00\n\tFries combo:\tadd $1.50\n\tSalad combo:\tadd $2.00")
order_main = str(input("Order B - burger or W - wings: "))
price = 0.0
price += main_course[order_main]
combo_status = str(input("Make it a combo? (Y/N): "))
if combo_status == 'Y':
order_combo = str(input("Add F - fries or S - salad: "))
price += combo[order_combo]
return price
total_price = fast_food()
print(f"Price: ${total_price}")
except:
print("Sorry! Selected food is not available.")
finally:
print("Thank you, visit again!")