Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 3, 2020 22:47
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/1caa6e17b089c0a5839019e3205a82de to your computer and use it in GitHub Desktop.
Save codecademydev/1caa6e17b089c0a5839019e3205a82de to your computer and use it in GitHub Desktop.
Codecademy export
def cost_ground(weight):
if weight<=2:
price=1.5
elif weight>=2 and weight<=6:
price=3
elif weight>=6 and weight<=10:
price=4
else:
price=4.75
return 20+(price*weight)
print(cost_ground(8.4))
cost_premium=125
def cost_drone(weight):
if weight<=2:
price=4.5
elif weight>=2 and weight<=6:
price=9
elif weight>=6 and weight<=10:
price=12
else:
price=14.25
return (price*weight)
print(cost_drone(1.5))
def best_price(weight):
ground=cost_ground(weight)
premium=cost_premium
drone=cost_drone(weight)
if ground < drone and ground < premium:
return "Ground Shipping is cheapest and will cost you "+str(cost_ground)
elif premium < ground and premium < drone:
return "Premium Ground Shipping is cheapest and will cost you "+str(cost_premium)
else:
return "Drone Shipping is cheapest and it will cost you " +str(cost_drone)
best_price(4.8)
best_price(41.5)
print(best_price(4.8))
print(best_price(41.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment