Advertisement
Spocoman

Family Trip

Feb 21st, 2022 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. budget = float(input())
  2. overnight = int(input())
  3. overnight_price = float(input())
  4. additional_costs = float(input())
  5.  
  6. if overnight > 7:
  7.     overnight_price *= 0.95
  8.  
  9. total_price = overnight * overnight_price + additional_costs * budget / 100
  10.  
  11. if total_price <= budget:
  12.     print(f"Ivanovi will be left with {budget - total_price:.2f} leva after vacation.")
  13. else:
  14.     print(f"{total_price - budget:.2f} leva needed.")
  15.  
  16.  
  17. Решение с тернарен оператор:
  18.  
  19. budget = float(input())
  20. overnight = int(input())
  21. overnight_price = float(input())
  22. additional_costs = float(input())
  23.  
  24. total_price = overnight * overnight_price * (0.95 if overnight > 7 else 1) + additional_costs * budget / 100
  25. diff = abs(total_price - budget)
  26.  
  27. print(f"Ivanovi will be left with {diff:.2f} leva after vacation." if total_price <= budget else f"{diff:.2f} leva needed.")
  28.  
  29.  
  30. Тарикатско решение:)
  31.  
  32. budget = float(input())
  33. overnight = int(input())
  34.  
  35. budget -= overnight * float(input()) * (0.95 if overnight > 7 else 1) + float(input()) * budget / 100
  36.  
  37. print(f"Ivanovi will be left with {budget:.2f} leva after vacation." if budget >= 0 else f"{abs(budget):.2f} leva needed.")
  38.  
  39.  
  40.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement