Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- amount = float(input())
- puzzles = int(input())
- dolls = int(input())
- bears = int(input())
- minions = int(input())
- trucks = int(input())
- puzzles_price = puzzles * 2.6
- dolls_price = dolls * 3
- bears_price = bears * 4.1
- minions_price = minions * 8.2
- trucks_price = trucks * 2
- toys = puzzles + dolls + bears + minions + trucks
- price = puzzles_price + dolls_price + bears_price + minions_price + trucks_price
- if toys >= 50:
- price *= 0.75
- price *= 0.9
- if price >= amount:
- print(f'Yes! {price - amount:.2f} lv left.')
- else:
- print(f'Not enough money! {amount - price:.2f} lv needed.')
- Решение с колекция:
- amount = float(input())
- toy_count = {
- 'puzzles': int(input()),
- 'dolls': int(input()),
- 'bears': int(input()),
- 'minions': int(input()),
- 'trucks': int(input())
- }
- toy_price = {
- 'puzzles': 2.60,
- 'dolls': 3.00,
- 'bears': 4.10,
- 'minions': 8.20,
- 'trucks': 2.00
- }
- total_count = sum(toy_count.values())
- total_price = 0
- for i in toy_price:
- total_price += toy_price[i] * toy_count[i]
- total_price *= 0.75 if total_count >= 50 else 1
- diff = total_price * 0.9 - amount
- print(f'Yes! {diff:.2f} lv left.' if diff >= 0 else f'Not enough money! {abs(diff):.2f} lv needed.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement