Spocoman

Series

Mar 15th, 2022 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. budget = float(input())
  2. volume = int(input())
  3.  
  4. for i in range(volume):
  5.     name = input()
  6.     cash = float(input())
  7.     if name == "Thrones":
  8.         cash /= 2
  9.     elif name == "Lucifer":
  10.         cash *= 0.6
  11.     elif name == "Protector":
  12.         cash *= 0.7
  13.     elif name == "TotalDrama":
  14.         cash *= 0.8
  15.     elif name == "Area":
  16.         cash *= 0.9
  17.        
  18.     budget -= cash
  19.  
  20. if budget >= 0:
  21.     print(f"You bought all the series and left with {budget:.2f} lv.")
  22. else:
  23.     print(f"You need {abs(budget):.2f} lv. more to buy the series!")
  24.  
  25.  
  26. Решение с тернарен оператор леко тарикатската:)
  27.  
  28. budget = float(input())
  29. volume = int(input())
  30.  
  31. for i in range(volume):
  32.     name = input()
  33.    
  34.     budget -= (0.5 if name == 'Thrones' else
  35.                0.6 if name == 'Lucifer' else
  36.                0.7 if name == 'Protector' else
  37.                0.8 if name == 'TotalDrama' else
  38.                0.9 if name == 'Area' else 1) * float(input())
  39.  
  40. print(f'You bought all the series and left with {budget:.2f} lv.' if budget >= 0
  41.       else f'You need {abs(budget):.2f} lv. more to buy the series!')
  42.  
Add Comment
Please, Sign In to add comment