SimeonTs

SUPyF2 Functions-Lab - 04. Orders

Oct 8th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. """
  2. Functions - Lab
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1727#3
  4.  
  5. SUPyF2 Functions-Lab - 04. Orders
  6.  
  7. Problem:
  8. Write a function that calculates the total price of an order and prints it on the console.
  9. The function should receive one of the following products: coffee, coke, water, snacks; and a quantity of the product.
  10. The prices for a single piece of each product are:
  11. • coffee - 1.50
  12. • water - 1.00
  13. • coke - 1.40
  14. • snacks - 2.00
  15. Print the result formatted to the second decimal place.
  16.  
  17. Example:
  18. Input:      Output:
  19.  
  20. water
  21. 5           5.00
  22.  
  23. coffee
  24. 2           3.00
  25. """
  26.  
  27.  
  28. def order(product, quantity):
  29.     if product == "coffee":
  30.         product = 1.50
  31.     elif product == "coke":
  32.         product = 1.40
  33.     elif product == "water":
  34.         product = 1.00
  35.     elif product == "snacks":
  36.         product = 2.00
  37.     return f"{(product * quantity):.2f}"
  38.  
  39.  
  40. print(order(input(), int(input())))
Add Comment
Please, Sign In to add comment