Answer to Question #251175 in Python for Caleb

Question #251175

You are assisting a Coffee Shop create a program to run at their kiosk for customers to purchase their items. You will create a program to create a dictionary of their current coffee products and prices:

Coffee item Price

Hot brew $4.25

Latte  4.75

Mocha  4.99

Cold brew  3.95

Cappuccino  4.89

Donut        1.50

Create a program in Python to accept input from a customer inquiring what item they would like to purchase. Customers can purchase more than one item. Test to see if the item they request is in your dictionary – if not display a message that you don’t currently carry that item. Total up the costs of all the items they wish to purchase and then display to them their total bill, including 7% tax.  


1
Expert's answer
2021-10-14T16:45:42-0400
drinks = {
    'Hot brew': 4.25,
    'Latte': 4.75,
    'Mocha': 4.99,
    'Cold brew': 3.95,
    'Cappuccino': 4.89,
    'Donut': 1.50
}
tax = 0.07
# example input: 'Mocha, Donut'
inp = input('Enter the names of the drinks, separated by commas with space: ').split(', ')

[print('We don\'t have {0}'.format(x)) for x in inp if x not in drinks]
price = sum([drinks[x] for x in inp if x in drinks])
price += round(price * tax, 2)

print('Total price: {0}'.format(price))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS