estimate_trip_cost.estimate_trip_cost

estimate_trip_cost.estimate_trip_cost(distance, fuel_price, efficiency)

Calculate the total fuel cost of a trip in Canada (Metric units), including a contingency fee for long trips. Adds 15% contingency for trips over 500 km to account for additional costs imposed by extended trips, ie. food, activities, etc.

Parameters

Name Type Description Default
distance float The distance of the trip in kilometers (km). required
fuel_price float The price of fuel per liter (CAD/L). required
efficiency float The fuel efficiency of the vehicle in kilometers per liter (km/L). required

Returns

Name Type Description
float The estimated cost of the trip rounded to 2 decimal places.

Raises

Name Type Description
ValueError If distance, fuel_price, or efficiency are less than or equal to zero.

Examples

>>> estimate_trip_cost(150, 1.7, 12)
21.25
>>> estimate_trip_cost(900, 1.7, 12)
146.62