Taxi Fare


# Program that calculates taxi fares using a function

# Defines the function fare_calculator to calculate the total cost
def fare_calculator(distance):
    """Returns the total taxi fare for a certain distance traveled:
        The necessary steps for calculation are:
        1. Base fare of $4.00.
        2. Conversion from kilometers to meters.
        3. Divide the meters traveled by 140 meters.
        4. Take the result from Step 3 and multiply it by 0.25.
        5. Take the result from Step 4 and add the base fare.
        6. The ending amount is the total cost."""
    BASE_FARE = 4.00 #PEP Style: constants are all uppercase
    kilometers_to_meters = distance * 1000 #1km = 1000m
    distance_to_multiply = kilometers_to_meters/140
    cost_for_distance = distance_to_multiply * 0.25
    total_cost = cost_for_distance + BASE_FARE
    return print(f"${total_cost:.2f}") # formatted as a floating value 
                                        # with two-decimal precision and a 
                                        # dollar sign in front 


# Calls upon the function and takes a value as an argument for the distance.
# Any distance in kilometers traveled can be placed between the parentheses.
fare_calculator()