Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created May 13, 2020 22:00
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/e71b55f236c4b95192deb7ebb95916d3 to your computer and use it in GitHub Desktop.
Save codecademydev/e71b55f236c4b95192deb7ebb95916d3 to your computer and use it in GitHub Desktop.
Codecademy export
def price_ground_shipping(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
cost= 20+(weight*price_per_pound)
return cost
print(price_ground_shipping(8.4))
price_ground_shipping= 125.00
def price_drone_shipping(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
cost= weight*price_per_pound
return cost
print(price_drone_shipping(1.5))
def cheapest_option(weight):
ground= price_ground_shipping(weight)
drone= price_drone_shipping(weight)
premium= price_premium_shipping
if ground < drone and ground < premium:
method="standar ground"
cost= ground
elif premium < ground and premium < drone:
method= "premium"
cost= premium
else:
method= "drone"
cost= drone
print("You should ship using $%.2f shipping, it will %s shipping"
%(cost,method) )
cheapest_option(4.8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment