-
-
Save codecademydev/0ac5340fed71944c903a33a6f9c7a065 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 cost_ground(weight): | |
if weight <= 2: | |
cost = weight * 1.5 + 20 | |
return cost | |
elif 2 < weight <= 6: | |
cost = weight * 3.0 + 20 | |
return cost | |
elif 6 < weight <= 10: | |
cost = weight * 4.0 + 20 | |
return cost | |
elif weight > 10: | |
cost = weight * 4.75 + 20 | |
return cost | |
else: | |
return Error | |
print ("Sth went wrong in cost_ground") | |
#print(cost_ground(8.4)) | |
cost_premium = 125.0 | |
def cost_drone(weight): | |
if weight <= 2: | |
cost = weight * 4.5 | |
return cost | |
elif 2 < weight <= 6: | |
cost = weight * 9.0 | |
return cost | |
elif 6 < weight <= 10: | |
cost = weight * 12.0 | |
return cost | |
elif weight > 10: | |
cost = weight * 14.25 | |
return cost | |
else: | |
return Error | |
print ("Sth went wrong in cost_drone") | |
print(cost_drone(1.5)) | |
def cheapest_shipping(weight): | |
if cost_ground(weight) < (cost_drone(weight) and cost_premium): | |
return "Ground shipping is the cheapest method for your shipment. It would cost " + str(cost_ground(weight)) + " Dollars." | |
elif cost_premium < (cost_drone(weight) and cost_ground(weight)): | |
return "Premium ground shipping is the cheapest method for your shipment. It would cost " + str(cost_premium) + " Dollars." | |
elif cost_drone(weight) < (cost_ground(weight) and cost_premium): | |
return "Drone shipping is the cheapest method for your shipment. It would cost " + str(cost_drone(weight)) + " Dollars." | |
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