-
-
Save codecademydev/582810beee5766fd8facf6d392ed1294 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: | |
return weight * 1.5 + 20 | |
elif weight > 2 and weight <= 6: | |
return weight * 3 + 20 | |
elif weight > 6 and weight <= 10: | |
return weight * 4 + 20 | |
elif weight > 10: | |
return weight * 4.75 + 20 | |
#print(ground_shipping(8.4)) | |
premium_ground_shipping_cost = 125 | |
def drone_shipping(weight): | |
if weight <= 2: | |
return weight * 4.5 + 0 | |
elif weight > 2 and weight <= 6: | |
return weight * 9 + 0 | |
elif weight > 6 and weight <= 10: | |
return weight * 12 + 0 | |
elif weight > 10: | |
return weight * 14.25 + 0 | |
#print(drone_shipping(1.5)) | |
def cheapest_shipping_method(weight): | |
if weight <= 2: | |
print("Drone Shipping is the cheapest.") | |
return weight * 4.5 + 0 | |
elif weight > 2 and weight <= 3.3: | |
#Here till weight 3.3 you'll notice that drone shipping is the cheapest option. Hence you need to form the intervals accordingly | |
print("Drone Shipping is the cheapest.") | |
return weight * 9 + 0 | |
elif weight > 3.3 and weight <= 6: | |
print("Ground Shipping is the cheapest.") | |
return weight * 3 + 20 | |
elif weight > 6 and weight <= 10: | |
print("Ground Shipping is the cheapest.") | |
return weight * 4 + 20 | |
elif weight > 10 and weight <= 22.1: | |
#Here henceforth 10 weight to 22.1052632 pounds you'll notice that ground shipping is the cheapest option. Hence you need to form the intervals accordingly | |
print("Ground Shipping is the cheapest.") | |
return weight * 4.75 + 20 | |
elif weight > 22.1: | |
print("Premium Ground Shipping is the cheapest.") | |
return premium_ground_shipping_cost | |
print(cheapest_shipping_method(4.8)) | |
print(cheapest_shipping_method(41.5)) | |
print(cheapest_shipping_method(3.3)) | |
print(cheapest_shipping_method(3.4)) | |
print(cheapest_shipping_method(22.1)) | |
print(cheapest_shipping_method(22.2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment