Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Решение с тернарен оператор:
- products = input().split('|')
- budget = float(input())
- cash = budget
- profit = []
- for p in products:
- p = p.split('->')
- product = p[0]
- price = float(p[1])
- max_price = 50.00 if product == 'Clothes' else 35.00 if product == 'Shoes' else 20.50
- if price <= cash and max_price >= price:
- profit.append(price * 1.4)
- cash -= price
- for price in profit:
- print(f'{price:.2f} ', end='')
- print(f'\nProfit: {sum(profit) - budget + cash:.2f}')
- print('Hello, France!' if sum(profit) + cash >= 150 else 'Not enough money.')
- Решение с речник и тернарен оператор:
- products = input().split('|')
- budget = float(input())
- cash = budget
- profit = []
- max_price = {'Clothes': 50.00, 'Shoes': 35.00, 'Accessories': 20.50}
- for p in products:
- p = p.split('->')
- product = p[0]
- price = float(p[1])
- if price <= cash and max_price[product] >= price:
- profit.append(price * 1.4)
- cash -= price
- for price in profit:
- print(f'{price:.2f} ', end='')
- print(f'\nProfit: {sum(profit) - budget + cash:.2f}')
- print('Hello, France!' if sum(profit) + cash >= 150 else 'Not enough money.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement