Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 29, 2020 14: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/eec3c04a98bc2c20ad313996651f109b to your computer and use it in GitHub Desktop.
Save codecademydev/eec3c04a98bc2c20ad313996651f109b to your computer and use it in GitHub Desktop.
Codecademy export
def cost_of_gs(weight):
if weight <= 2:
price_per_lb = 1.5
elif weight <= 6:
price_per_lb = 3
elif weight <= 10:
price_per_lb = 4
else:
price_per_lb = 4.75
return (weight * price_per_lb) + 20
print(cost_of_gs(8.4))
cost_of_pgs = 125
def cost_of_ds(weight):
if weight <= 2:
price_per_lb = 4.5
elif weight <= 6:
price_per_lb = 9
elif weight <= 10:
price_per_lb = 12
else:
price_per_lb = 14.25
return (weight * price_per_lb)
print(cost_of_ds(1.5))
def cheapest_method(weight):
ground = cost_of_gs(weight)
premium = cost_of_pgs
drone = cost_of_ds(weight)
if ground < premium and ground < drone:
method = "standard ground."
cost = ground
elif premium < ground and premium < drone:
method = "premium ground."
cost = premium
else:
method = "drone."
cost = drone
print("the cheapest option available is " + str(cost) + " with " + method)
print(cheapest_method(4.8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment