Advertisement
anton_d

09. hello_france

Jun 22nd, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. # $150
  2. # 40% markUP
  3. # {type->price|type->price|}
  4. # {budget}
  5.  
  6. # Don't buy item if price is above as follows:
  7. # Clothes = max(50.00)
  8. # Shoes = max(35.00)
  9. # Accessories = max(20.50)
  10.  
  11. # max prices
  12. CLOTHES_MAX_PRICE = 50
  13. SHOES_MAX_PRICE = 35
  14. ACCESSORIES_MAX_PRICE = 20.50
  15.  
  16. items = input()
  17. budget = float(input())
  18.  
  19. items_list = items.split("|")
  20.  
  21. new_price = []
  22. profit = 0
  23. bought = 0
  24.  
  25. item_type, value = '', 0
  26. for item in items_list:
  27.     item_type, price = item.split("->")
  28.     value = float(price)
  29.     if value > budget:
  30.         continue
  31.  
  32.     if (item_type == "Clothes" and 0 < value < CLOTHES_MAX_PRICE) or \
  33.             (item_type == "Shoes" and 0 < value < SHOES_MAX_PRICE) or \
  34.             (item_type == "Accessories" and 0 < value < ACCESSORIES_MAX_PRICE):
  35.         budget -= value
  36.         bought += value
  37.         value = value * 1.40
  38.         y = round(value, 2)
  39.         new_price.append(y)
  40. for i in new_price:
  41.     profit += i
  42. print(" ".join(map(str, new_price)))
  43. print("Profit: {:.2f}".format(profit - bought))
  44.  
  45. if profit + budget >= 150:
  46.     print("Hello, France!")
  47. else:
  48.     print("Not enough money.")
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement