Advertisement
Spocoman

04. Transport Price

Dec 18th, 2021 (edited)
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. km = int(input())
  2. time = input()
  3. price = 0
  4.  
  5. if km < 20:
  6.     if time == "day":
  7.         price = km * 0.79 + 0.7
  8.     else:
  9.         price = km * 0.9 + 0.7
  10. elif km >= 100:
  11.     price = km * 0.06
  12. else:
  13.     price = km * 0.09
  14.  
  15. print(f"{price:.2f}")
  16.  
  17. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  18.  
  19. km = int(input())
  20. time = input()
  21.  
  22. price = km * (0.79 if time == "day" else 0.9) + 0.7 if km < 20 else km * 0.06 if km >= 100 else km * 0.09
  23.  
  24. print(f"{price:.2f}")
  25.  
  26. Или леко тарикатската:
  27.  
  28. km = int(input())
  29.  
  30. print(f'{(km * (0.79 if input() == "day" else 0.9) + 0.7 if km < 20 else km * 0.06 if km >= 100 else km * 0.09):.2f}')
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement