Advertisement
Osiris1002

09. Hello, France

Feb 5th, 2024
1,117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. def buy_items_and_calculate_profit(items, budget):
  2.     max_prices = {"Clothes": 50.00, "Shoes": 35.00, "Accessories": 20.50}
  3.     bought_items = []
  4.     total_profit = 0
  5.  
  6.     for item in items:
  7.         item_type, price = item.split("->")
  8.         price = float(price)
  9.         if price <= max_prices[item_type] and budget >= price:
  10.             budget -= price
  11.             bought_items.append(price * 1.4)
  12.             total_profit += price * 0.4
  13.  
  14.     return bought_items, total_profit, budget
  15.  
  16.  
  17. def main():
  18.     items_input = input().split("|")
  19.     budget = float(input())
  20.  
  21.     bought_items, profit, remaining_budget = buy_items_and_calculate_profit(items_input, budget)
  22.     total_budget = sum(bought_items) + remaining_budget
  23.  
  24.     print(" ".join(f"{price:.2f}" for price in bought_items))
  25.  
  26.     print(f"Profit: {profit:.2f}")
  27.  
  28.     if total_budget >= 150:
  29.         print("Hello, France!")
  30.     else:
  31.         print("Not enough money.")
  32.  
  33.  
  34. main()
Tags: hello france
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement