Hello,
Could you, please, help me understand what is happening with my code below?
I could not find out the cause of the problem. Thanks
def ground_shipping(weight):
if weight <= 2:
return weight * 1.50 + 20.00
elif weight <= 6:
return weight * 3.00 + 20.00
elif weight <= 10:
return weight * 4.00 + 20.00
else:
return weight * 4.75 + 20.00
print(ground_shipping(8.4))
premium_shipping = 125.00
def drone_shipping(weight):
if weight <= 2:
return weight * 4.50
elif weight <= 6:
return weight * 9.00
elif weight <= 10:
return weight * 12.00
else:
return 14.25
print(drone_shipping(1.5))
def cheapest_shipping(weight):
ground = ground_shipping(weight)
drone = drone_shipping(weight)
premium = premium_shipping
if ground < drone and ground < premium:
method = âGround_shippingâ
cost = ground
elif premium < ground and premium < drone:
method = âPremium_shippingâ
cost = premium
else:
method = âDrone_shippingâ
cost = drone
print(
âThe cheapest option available is $%.2f with %s.â
% (cost, method)
)
53.6
6.75
Traceback (most recent call last):
File âscript.pyâ, line 43, in
% (cost, method)
NameError: name âcostâ is not defined