Last active
April 1, 2020 11:04
-
-
Save somodiferenc/e9b48375291cb8c4c2b0b13be07fa556 to your computer and use it in GitHub Desktop.
Python_practice_project
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
price_ground_1 = 1.50 | |
price_ground_2 = 3.0 | |
price_ground_3 = 4.0 | |
price_ground_4 = 4.75 | |
price_premium = 125.0 | |
price_drone_1 = 4.50 | |
price_drone_2 = 9.0 | |
price_drone_3 = 12.0 | |
price_drone_4 = 14.25 | |
# function to calculate ground shipping cost | |
def cost_ground_shipping(weight): | |
cost1 = 20 + weight * price_ground_1 | |
cost2 = 20 + weight * price_ground_2 | |
cost3 = 20 + weight * price_ground_3 | |
cost4 = 20 + weight * price_ground_4 | |
if weight < 2: | |
return cost1 | |
elif 2 < weight <= 6: | |
return cost2 | |
elif 6 < weight <= 10: | |
return cost3 | |
elif weight > 10: | |
return cost4 | |
#print(cost_ground_shipping(8.4)) | |
# function to calculate drone shipping cost | |
def cost_drone_shipping(weight): | |
cost1 = weight * price_drone_1 | |
cost2 = weight * price_drone_2 | |
cost3 = weight * price_drone_3 | |
cost4 = weight * price_drone_4 | |
if weight < 2: | |
return cost1 | |
elif 2 < weight <= 6: | |
return cost2 | |
elif 6 < weight <= 10: | |
return cost3 | |
elif weight > 10: | |
return cost4 | |
# compare different shipping options | |
def compare(weight): | |
ground = cost_ground_shipping(weight) | |
drone = cost_drone_shipping(weight) | |
if ground < drone and ground < price_premium: | |
return "The cheapest shipping method is ground shipping. " + "It costs " + str(ground) | |
elif drone < ground and drone < price_premium: | |
return "The cheapest shipping method is drone shipping. " + "It costs " + str(drone) | |
elif price_premium < ground and price_premium < drone: | |
return "The cheapest shipping method is premium ground shipping. " + "It costs " + str(price_premium) | |
#test | |
print(compare(4.8)) | |
print(compare(41.5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment