Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 1, 2020 15:18
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/cbf160fee4be7fe7d489a12caa953885 to your computer and use it in GitHub Desktop.
Save codecademydev/cbf160fee4be7fe7d489a12caa953885 to your computer and use it in GitHub Desktop.
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