Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created October 6, 2020 02:41
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/f3f68bcc220be70e9e18f10137d4d45c to your computer and use it in GitHub Desktop.
Save codecademydev/f3f68bcc220be70e9e18f10137d4d45c to your computer and use it in GitHub Desktop.
Codecademy export
def ground_shipping(weight):
if weight <= 2:
cost = 1.50
elif weight <= 6:
cost = 3.00
elif weight <= 10:
cost = 4.00
else: cost = 4.75
return 20 + cost * weight
def drone_shipping(weight):
if weight <= 2:
cost = 4.50
elif weight <= 6:
cost = 9.00
elif weight <= 10:
cost = 14.25
else: cost = 14.25
return 0 + cost * weight
premium = 125.00
def cheapest_shipping(weight):
drone = drone_shipping(weight)
ground = ground_shipping(weight)
if drone < premium and drone < ground:
method = "drone shipment "
cost = drone
elif premium < drone and premium < ground:
method = "premium shipment "
cost = premium
else:
cost = ground
method = "ground shipment "
return method + str(cost)
print(cheapest_shipping(41.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment