-
-
Save codecademydev/45b625891ae265e2b80fd52ecd27ac64 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_of_ground(weight): | |
if weight<=2 : | |
price=1.5 | |
elif weight<2 and weight<=6: | |
price=3 | |
elif weight>6 and weight<=10: | |
price=4.0 | |
else: | |
price=4.75 | |
return 20+(weight*price) | |
print(cost_of_ground(8.4)) | |
def cost_of_drone(weight): | |
if weight<=2 : | |
price=4.5 | |
elif weight<2 and weight<=6: | |
price=9 | |
elif weight>6 and weight<=10: | |
price=12 | |
else: | |
price=14.25 | |
return weight*price | |
print(cost_of_drone(1.5)) | |
premium_ground=125.0 | |
def print_cheaphest_shiphing_method(weight): | |
ground=cost_of_ground(weight) | |
drone=cost_of_drone(weight) | |
premium=premium_ground | |
if ground < drone and ground < premium : | |
method="standard ground" | |
cost=ground | |
elif drone < ground and drone < premium : | |
method="drone transport" | |
cost=drone | |
else: | |
method="premium ground transport" | |
cost=premium | |
print("Best price for you is $%.2f with %s shiphing" | |
% (method,cost)) | |
print_cheaphest_shiphing_method(4.8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment