Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 1, 2020 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/421e273fe67239d1a67d582503419966 to your computer and use it in GitHub Desktop.
Save codecademydev/421e273fe67239d1a67d582503419966 to your computer and use it in GitHub Desktop.
Codecademy export
def ground_cost(weight):
if weight <= 2:
ground_cost = 20 + (weight * 1.50)
elif weight <= 6:
ground_cost = 20 + (weight * 3.00)
elif weight <= 10:
ground_cost = 20 + (weight * 4.00)
else:
ground_cost = 20 + (weight * 4.75)
return ground_cost
print(ground_cost(8.4))
premium_ground_cost = 125
def drone_cost(weight):
if weight <= 2:
drone_cost = weight * 4.50
elif weight <= 6:
drone_cost = weight * 9.00
elif weight <= 10:
drone_cost = weight * 12.00
else:
drone_cost = weight * 14.25
return drone_cost
print(drone_cost(1.5))
def user_choice (weight):
ground = ground_cost(weight)
drone = drone_cost(weight)
premium = premium_ground_cost
if ground < drone:
if ground < premium:
print:("You should use ground shipping. It will cost you " + str(ground))
else:
print:("You should use premium ground shipping. It will cost you " + str(premium) + ".")
elif drone < ground:
if drone < premium:
print ("You should use drone shipping. It will cost you " + str(drone) + ".")
else:
print ("You should use premium ground shipping. It will cost you " + str(premium) + ".")
user_choice(4.8)
user_choice(41.5)
print(user_choice(4.8))
print(user_choice(41.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment