The Nile Project Python

Hi

I’ve gone through walk through and checked my code but the last pass test says this:

OK! calculate_shipping_cost() passes tests
OK! calculate_driver_cost() passes tests
calculate_driver_cost() did not provide correct final price (expected 260, received 445)

can you please tell me where I went wrong?

This is my code:

from NILE import get_distance, format_price, SHIPPING_PRICES
from TEST import test_function

Define calculate_shipping_cost() here:

def calculate_shipping_cost(from_coords, to_coords, shipping_type=“Overnight”): #1 and #7
from_lat, from_long=from_coords#2
to_lat, to_long=to_coords#2
distance=get_distance(from_lat, from_long, to_lat, to_long)#3
shipping_rate=SHIPPING_PRICES[shipping_type]#4
price=distance*shipping_rate#5
return format_price(price)#6

Test the function by calling

test_function(calculate_shipping_cost)#8

Define calculate_driver_cost() here

def calculate_driver_cost(distance, drivers):#9
cheapest_driver= None #10
cheapest_driver_price= None#10
for driver in drivers: #11
driver_time= driver.speed
distance#12
price_for_driver=driver.salary*driver_time#13
if cheapest_driver is None:#14
cheapest_driver=driver#14
cheapest_driver_price=price_for_driver#14
elif price_for_driver<cheapest_driver_price:#15
cheapest_driver=driver#15
cheapest_driver_price=price_for_driver#15
return cheapest_driver_price, cheapest_driver#16

Test the function by calling

test_function(calculate_driver_cost) #16

Define calculate_money_made() here

def calculate_money_made(**trips):#17 this will now be a dictionary using astericks
total_money_made=0 #18
for trip_id, trip in trips.items():#19
trip_revenue=trip.cost-trip.driver.cost #20
total_money_made+=trip_revenue #21
return total_money_made #22

Test the function by calling

test_function(calculate_money_made) #23