-
-
Save codecademydev/f3f68bcc220be70e9e18f10137d4d45c to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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