-
-
Save codecademydev/2a07b5f0906a0e57dce21ef63403e1fb 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): | |
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 | |
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 | |
premium_ground_charge = 125.00 | |
def cheapest_shipping(weight): | |
premium = premium_ground_charge | |
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: method = "ground shipment " | |
cost = ground | |
return method + str(cost) | |
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