Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created Oct 5, 2020
Embed
What would you like to do?
Codecademy export
def ground_shipping(weight):
flat_charge = 20
if weight <= 2:
cost = 1.50
elif weight <= 6:
cost = 3.00
elif weight <= 10:
cost = 4.00
else: cost = 4.75
return flat_charge + cost * weight
premium_ground_charge = 125.00
def drone_shipping(weight):
flat_charge = 0.00
if weight <= 2:
cost = 4.50
elif weight <= 6:
cost = 9.00
elif weight <= 10:
cost = 14.25
else: cost = 14.25
return flat_charge + cost * weight
def cheapest_shipping(weight):
drone = drone_shipping(weight)
ground = ground_shipping(weight)
premium = primium_ground_charge
if drone < premium and drone < ground:
return "drone shipment will be the cheapest "+ str(drone)
elif premium < drone and premium < ground:
return "premium shipment will be the cheapest " + str(premium)
else: "ground shipment will be the cheapest " + str(ground)
print(cheapest_shipping(4.8))
print(cheapest_shipping(41.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment