Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. # Exam, Pr. 04. Wedding Decoration
  2. budget = float(input()) # бюджетът с който разполагат за украсата – реално число
  3. type_of_goods = input() # Видът на стоката ("balloons", "flowers", "candles", "ribbon")
  4. current_price = 0
  5. text = "Purchased decoration is"
  6. text_balloons = ""
  7. text_ribbon = ""
  8. text_flowers = ""
  9. text_candles = ""
  10. total_cost = 0
  11. num_balloons = 0
  12. num_flowers = 0
  13. num_candles = 0
  14. num_ribbon = 0
  15.  
  16. while type_of_goods != "stop":
  17. num_of_goods = int(input()) # Броят – балоните, цветята и свещите в бр., а панделката в метри – цяло число
  18. if type_of_goods == "balloons":
  19. num_balloons += num_of_goods
  20. current_price = num_of_goods * 0.1
  21. total_cost += current_price
  22. text_balloons = f"{num_balloons} balloons,"
  23. elif type_of_goods == "flowers":
  24. num_flowers += num_of_goods
  25. current_price = num_of_goods * 1.5
  26. total_cost += current_price
  27. text_flowers = f"{num_flowers} flowers"
  28. elif type_of_goods == "candles":
  29. num_candles += num_of_goods
  30. current_price = num_of_goods * 0.5
  31. total_cost += current_price
  32. text_candles = f"and {num_candles} candles."
  33. elif type_of_goods == "ribbon":
  34. num_ribbon += num_of_goods
  35. current_price = num_of_goods * 2
  36. total_cost += current_price
  37. text_ribbon = f"{num_ribbon} m ribbon,"
  38. # print(f"Good: {type_of_goods}, current price: {current_price}")
  39. budget -= current_price
  40. # print(f"Current budget: {budget}")
  41. if budget <= 0:
  42. print("All money is spent!")
  43. break
  44. type_of_goods = input() # Видът на стоката ("balloons", "flowers", "candles", "ribbon")
  45.  
  46. if type_of_goods == "stop":
  47. print(f"Spend money: {total_cost:.2f}")
  48. print(f"Money left: {budget:.2f}")
  49.  
  50. print(f"{text} {text_balloons} {text_ribbon} {text_flowers} {text_candles}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement