Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 26, 2020 19:37
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/0371fd4257116e00aecb65f6995c7b8e to your computer and use it in GitHub Desktop.
Save codecademydev/0371fd4257116e00aecb65f6995c7b8e to your computer and use it in GitHub Desktop.
Codecademy export
def Ground_sh_cost(weight):
if weight<=2:
cost = 20 + weight*1.5
elif weight<=6:
cost = 20 + weight*3
elif weight<=10:
cost = 20 + weight*4
elif 10<weight:
cost = 20 + weight*4.75
return cost
Premium_cost = 125.0
def Drone_sh_cost(weight):
if weight<=2:
cost = weight*4.5
elif weight<=6:
cost = weight*9.0
elif weight<=10:
cost = weight*12.0
elif weight>10:
cost = weight*14.25
return cost
def Cheapest_cost(weight):
Ground_cost = Ground_sh_cost(weight)
Drone_cost = Drone_sh_cost(weight)
if Ground_cost<=Drone_cost and Drone_cost<=Premium_cost:
method = "ground shipping"
cost = Ground_cost
elif Drone_cost<=Ground_cost and Ground_cost<=Premium_cost:
method = "drone shipping"
cost = Drone_cost
elif Premium_cost<=Drone_cost and Drone_cost<=Ground_cost:
method = "premium shipping"
cost = Premium_cost
print(
"The cheapest shipping cost is $%.2f using %s."
% (cost, method)
)
Cheapest_cost(5)
Cheapest_cost(12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment