Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 1, 2020 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/6ae9dd91bc73a1df63b8ccbce8923fa4 to your computer and use it in GitHub Desktop.
Save codecademydev/6ae9dd91bc73a1df63b8ccbce8923fa4 to your computer and use it in GitHub Desktop.
Codecademy export
def cost_ground_shipping(weight):
if weight <= 2:
cost = weight * 1.50 + 20
return(cost)
elif (weight >= 2) and (weight <= 6):
cost = weight * 3.00 + 20
return(cost)
elif (weight >= 6) and (weight <= 10):
cost = weight * 4.00 + 20
return(cost)
elif (weight >= 10):
cost = weight * 4.75 + 20
return(cost)
print("The cost of ground shipping is $" + str(cost_ground_shipping(4.8)) + ".")
premium_shipping_cost = 125.00
def cost_drone_shipping(weight):
if weight <= 2:
cost = weight * 4.50
return(cost)
elif (weight >= 2) and (weight <= 6):
cost = weight * 9.00
return(cost)
elif (weight >= 6) and (weight <= 10):
cost = weight * 12.00
return(cost)
elif (weight >= 10):
cost = weight * 14.25
return(cost)
print("The cost of drone shipping is $" + str(cost_drone_shipping(4.8)) + ".")
def cheapest_shipping_method(weight):
ground = cost_ground_shipping(weight)
premium = premium_shipping_cost
drone = cost_drone_shipping(weight)
if ground < drone and ground < premium:
return "Ground shipping is cheapest. The cost of ground shipping is $" + str(ground) + "."
elif drone < ground and drone < premium:
return "Drone shipping is cheapest. The cost of drone shipping is $" + str(drone) + "."
elif premium < ground and premium < drone:
return "Premium shipping is cheapest. The cost of premium shipping is $" + str(premium) + "."
print(cheapest_shipping_method(4.8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment