Skip to content

Instantly share code, notes, and snippets.

@codecademydev codecademydev/script.py Secret

Created Jun 1, 2020
Embed
What would you like to do?
Codecademy export
def cost_function(weight):
cost=''
if weight<=2:
cost=weight*1.5+20
elif weight>2 and weight<=6:
cost=weight*3+20
elif weight>6 and weight<=10:
cost=weight*4+20
elif weight>10:
cost=weight*4.75+20
return cost
def premium(weight):
cost=125
return cost
def drone_cost_function(weight):
cost=''
if weight<=2:
cost=weight*4.5
elif weight>2 and weight<=6:
cost=weight*9
elif weight>6 and weight<=10:
cost=weight*12
elif weight>10:
cost=weight*14.25
return cost
def min_cost(weight):
if drone_cost_function(weight)<cost_function(weight) and drone_cost_function(weight)<premium(weight) :
print("Drone shipping is cheaper as it costs "+str(drone_cost_function(weight))+" to ship "+str(weight)+" pound package")
elif cost_function(weight)<drone_cost_function(weight) and cost_function(weight)<premium(weight):
print("ground shipping is cheaper as it costs "+str(cost_function(weight))+" to ship "+str(weight)+" pound package")
elif premium(weight)<drone_cost_function(weight) and premium(weight)<cost_function(weight):
print("Premium shipping is cheaper as it costs "+str(premium(weight))+" to ship "+str(weight)+" pound package")
min_cost(41.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.