Advertisement
ALEXANDAR_GEORGIEV

transport_price

Jun 14th, 2022
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. distance_km = int(input()) # растояние за пътуване
  2. day_or_night = input()      # дали ще пътува през деня или през ноща
  3. min_sum = 0.00
  4. taxi_day = 0.70 + distance_km * 0.79
  5. taxi_night = 0.70 + distance_km * 0.90
  6. autobus = distance_km * 0.09 # Само око растоянието е >= 20 км
  7. train = distance_km * 0.06      # Само ако растоянието е >= 100 км
  8.  
  9. if distance_km < 20 and day_or_night == "day":
  10.     print(f"{taxi_day:.2f}")
  11. elif distance_km < 20 and day_or_night == "night":
  12.     print(f"{taxi_night:.2f}")
  13. elif 20 <= distance_km < 100 and day_or_night == "day":
  14.     if taxi_day > autobus:
  15.         print(f"{autobus:.2f}")
  16.     elif taxi_day < autobus:
  17.         print(f"{taxi_day:.2f}")
  18.     else:
  19.         print(f"{autobus:.2f}")
  20. elif 20 <= distance_km < 100 and day_or_night == "night":
  21.     if taxi_night > autobus:
  22.         print(f"{autobus:.2f}")
  23.     elif taxi_night < autobus:
  24.         print(f"{taxi_night:.2f}")
  25.     else:
  26.         print(f"{autobus:.2f}")
  27. elif distance_km >= 100 and day_or_night == "day":
  28.     list_of_transport_day = [taxi_day, autobus, train]
  29.     min_sum = min(list_of_transport_day)
  30.     print(f"{min_sum:.2f}")
  31. elif distance_km >= 100 and day_or_night == "night":
  32.     list_of_transport_night = [taxi_night, autobus, train]
  33.     min_sum = min(list_of_transport_night)
  34.     print(f"{min_sum:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement