https://www.codecademy.com/courses/learn-python-3/projects/sals-shipping
I am using this code but is not giving the expected output. Please help.
def ground_shipping_cost(weight):
if weight <= 2:
ground_shipping_cost = 20 + 1.5*weight
elif 2 < weight <= 6:
ground_shipping_cost = 20 + 3*weight
elif 6 < weight <= 10:
ground_shipping_cost = 20 + 4*weight
elif 10 < weight:
ground_shipping_cost = 20 + 4.75*weight
return ground_shipping_cost
ground_shipping_cost(8.4)
print(ground_shipping_cost(8.4))
premium_ground_shipping_cost= 125
def drone_shipping_cost(weight):
if weight <= 2:
drone_shipping_cost = 4.5*weight
elif 2 < weight <= 6:
drone_shipping_cost = 9*weight
elif 6 < weight <= 10:
drone_shipping_cost = 12*weight
elif 10 < weight:
drone_shipping_cost= 14*weight
return drone_shipping_cost
drone_shipping_cost(1.5)
print(drone_shipping_cost(1.5))
def print_cheapest_method(weight):
ground=ground_shipping_cost(weight)
premium=premium_ground_shipping_cost(weight)
drone=drone_shipping_cost(weight)
if ground < premium and ground < drone:
method = "Ground Shipping"
cost = ground
elif premium < ground and premium < drone:
method = "Premium Ground Shipping"
cost = premium
else:
method = "Drone Shipping"
cost = drone
print (
"The cheapeast option available is $%f with %s shipping."
% (cost, method)
)
print(print_cheapest_method(4.8))
print(print_cheapest_method(41.5))
HELP: This code is NOT showing the cheapest way to ship 4.8 pound package is using ground shipping and it will cost $34.40 and the cheapest way to ship a 41.5 pound package is using premium ground shipping and it will cost $125.00.
What am I missing? Thanks