Advertisement
Spocoman

Safari

Mar 15th, 2022
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. budget = float(input())
  2. fuel = float(input())
  3. day = input()
  4.  
  5. total = fuel * 2.1 + 100
  6.  
  7. if day == "Saturday":
  8.     total *= 0.9
  9. else:
  10.     total *= 0.8
  11.  
  12. if budget >= total:
  13.     print(f"Safari time! Money left: {budget - total:.2f} lv. ")
  14. else:
  15.     print(f"Not enough money! Money needed: {total - budget:.2f} lv.")
  16.  
  17.  
  18. Решение с тернарен оператор:
  19.  
  20. budget = float(input())
  21. fuel = float(input())
  22. day = input()
  23.  
  24. total = (fuel * 2.1 + 100) * (0.9 if day == "Saturday" else 0.8)
  25.  
  26. print(f"Safari time! Money left: {budget - total:.2f} lv. " if budget >= total
  27.       else f"Not enough money! Money needed: {total - budget:.2f} lv.")
  28.  
  29.  
  30. Тарикатско решение:)
  31.  
  32. total = float(input()) - ((float(input()) * 2.1 + 100) * (0.9 if input() == "Saturday" else 0.8))
  33.  
  34. print(f"Safari time! Money left: {total:.2f} lv. " if total >= 0 else f"Not enough money! Money needed: {abs(total):.2f} lv.")
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement