-
-
Save codecademydev/afe6d35f9bbded3ff93c0ec1021103e7 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_cost (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 | |
return (weight * price_per_pound) + 20.00 | |
print(ground_shipping_cost (8.4)) | |
premium_ground_shipping = 125.00 | |
def drone_shipping_cost (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 | |
return (weight * price_per_pound) + 0.00 | |
print (drone_shipping_cost (1.5)) | |
def print_cheapest_shipping_method (weight): | |
ground = ground_shipping_cost (weight) | |
drone = drone_shipping_cost (weight) | |
premium = premium_ground_shipping | |
if ground < drone and ground < premium: | |
method = "ground shipping" | |
cost = ground | |
elif premium < drone and premium < ground: | |
method = "premium" | |
cost = premium | |
else: | |
method = "drone shipping" | |
cost = drone | |
print ("You should ship using " + method + ", it will cost " + "$" + str(cost) + ".") | |
print (print_cheapest_shipping_method (4.8)) | |
print (print_cheapest_shipping_method (41.5)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment