Python Programming – John Zelle: Chapter 3 ex. 5

The Konditorei coffee shop sells coffee at $10.50 a pound plus the cost of shipping. Each order ships for $0.86 per pound + $1.50 fixed cost for overhead. Write a program that calculates the cost of an order.

Chapter 3 Exercise 5

Python

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #Chapter 3 Exercise 5 #The Konditorei coffee shop sells coffee at $10.50 a pound plus the cost of shipping. # Each order ships for $0.86 per pound + $1.50 fixed cost for overhead. # Write a program that calculates the cost of an order. def main(): print("This program calculates the cost of a coffee order.") print() pounds = eval(input("Please enter how many pounds of coffee you would like to order ")) cost = ((10.50 + .86) * pounds) + 1.50 print("The total total cost of your order is", cost) main() |

Run =

This program calculates the cost of a coffee order.

Please enter how many pounds of coffee you would like to order 4

The total total cost of your order is 46.94