simeonshopov

Hello, France 2 variants

Dec 2nd, 2019
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.86 KB | None | 0 0
  1. items = input().split('|')
  2. budget = float(input())
  3. money = budget
  4. bought = []
  5. profit = 0
  6. '''
  7. макар начина на извличане на цената да е различен с долния код това не оказа влияние на резултата. Другите 2 неща посочени с коментари бяха разковничето да стане 0/100 до 100/100.
  8. '''
  9. for item in items:
  10.     new_price = 0
  11.     price = float(item[item.index('>') + 1:])  
  12.     if ('Clothes' in item and price <= 50) or ('Shoes' in item and price <= 35) or\
  13.             ('Accessories' in item and price <= 20.50):
  14.         if budget >= price:
  15.             budget -= price
  16.             new_price = price * 1.4
  17.             bought.append(str(round(new_price, 2)))  #тук е едната разлика с долния код
  18.             profit += (new_price - price)
  19. money += profit
  20.  
  21. print(' '.join(bought))  # тук е втората разлика с другия код.
  22. print(f'Profit: {profit:.2f}')
  23. if money >= 150:
  24.     print('Hello, France!')
  25. else:
  26.     print('Time to go.')
  27.  
  28. #############################################################################################
  29.  
  30. items = input().split('|')
  31. budget = float(input())
  32. new_budget = budget
  33. bought = []
  34. profit = 0
  35.  
  36. for item in items:
  37.     item = item.split('->')
  38.     obj = item[0]
  39.     price = float(item[1])
  40.     new_price = 0
  41.     if (obj == 'Clothes' and price <= 50) or (obj == 'Shoes' and price <= 35) or (obj == 'Accessories' and price <= 20.5):
  42.         if budget >= price:
  43.             budget -= price
  44.             new_price = price * 1.4
  45.             profit += new_price - price
  46.             bought.append(f'{new_price:.2f}')
  47.  
  48. new_budget += profit
  49. print(*bought)
  50. print(f'Profit: {profit:.2f}')
  51. if new_budget >= 150:
  52.   print('Hello, France!')
  53. else:
  54.   print('Time to go.')
Advertisement
Add Comment
Please, Sign In to add comment