Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 3, 2020 11:57
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/afe6d35f9bbded3ff93c0ec1021103e7 to your computer and use it in GitHub Desktop.
Save codecademydev/afe6d35f9bbded3ff93c0ec1021103e7 to your computer and use it in GitHub Desktop.
Codecademy export
def ground_shipping_cost (weight):
if weight <= 2:
price_per_pound = 1.50
elif weight <= 6:
price_per_pound = 3.00
elif weight <= 10:
price_per_pound = 4.00
else:
price_per_pound = 4.75
return (weight * price_per_pound) + 20.00
print(ground_shipping_cost (8.4))
premium_ground_shipping = 125.00
def drone_shipping_cost (weight):
if weight <= 2:
price_per_pound = 4.50
elif weight <= 6:
price_per_pound = 9.00
elif weight <= 10:
price_per_pound = 12.00
else:
price_per_pound =14.25
return (weight * price_per_pound) + 0.00
print (drone_shipping_cost (1.5))
def print_cheapest_shipping_method (weight):
ground = ground_shipping_cost (weight)
drone = drone_shipping_cost (weight)
premium = premium_ground_shipping
if ground < drone and ground < premium:
method = "ground shipping"
cost = ground
elif premium < drone and premium < ground:
method = "premium"
cost = premium
else:
method = "drone shipping"
cost = drone
print ("You should ship using " + method + ", it will cost " + "$" + str(cost) + ".")
print (print_cheapest_shipping_method (4.8))
print (print_cheapest_shipping_method (41.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment