In a particular jurisdiction, taxi fares consist of a base fare of $4.00, plus $0.25 for every 140 meters traveled. Write a function that takes the distance traveled (in kilometers) as its only parameter and returns the total fare as its only result. Write a main program that demonstrates the function.
Hint:
Taxi fares change over time. Use constants to represent the base fare and the variable portion of the fare so that the program can be updated easily when the rates increase.
#Constants BASE_FARE = 4.00 VARIABLE_FARE = 0.25 def taxi_fare(distance_km): #Convert to meters and floor divide with 140 distance_units = (distance_km*1000) // 140 totalFare = distance_units * VARIABLE_FARE totalFare += BASE_FARE return totalFare def main(): print("The fare is $",taxi_fare(12)) if __name__ == '__main__': main()