Hey everyone! I’ve been fiddling with Sal’s Shipping project for a few hours and can’t seem to get it to work. Can anyone help me figure out what’s wrong with my code?
This is what I originally had:
…
…
…
prem_ground = 125.00
def ground(weight):
if weight > 10.0:
return (weight * 4.75) + 20.0
elif weight > 6.0:
return (weight * 4.00) + 20.0
elif weight > 2.0:
return (weight * 3.00) + 20.0
else:
return (weight * 1.50) + 20.0
return ground(weight)
def drone(weight):
if weight > 10.0:
return weight * 14.25
elif weight > 6.0:
return weight * 12.00
elif weight > 2.0:
return weight * 9.00
else:
return weight * 4.50
return drone(weight)
def cheapest_shipping(weight):
if drone(weight) <= ground(weight) and drone(weight) <= prem_ground:
return "You should use Drone shipping, it will cost " + str(drone(weight))
elif prem_ground(weight) < ground(weight) and prem_ground(weight) < drone(weight):
return "You should use Premium Ground shipping, it will cost " + str(prem_ground)
elif ground(weight) < prem_ground(weight) and ground(weight) < drone(weight):
return "You should use Ground shipping, it will cost " + str(ground(weight))
cheapest_shipping(17)
…
…
…
…
…
…
This is what I’m trying now, with no luck:
prem_ground = 125.00
def ground(weight):
if weight > 10.0:
ppp = 4.75
elif weight > 6.0:
ppp = 4.00
elif weight > 2.0:
ppp = 3.00
else:
ppp = 1.50
return (ppp * weight) + 20
def drone(weight):
if weight > 10.0:
ppp = 14.25
elif weight > 6.0:
ppp = 12.00
elif weight > 2.0:
ppp = 9.00
else:
ppp = 4.50
return (ppp * weight)
def cheapest_shipping(weight):
ground = ground(weight)
drone = drone(weight)
prem = prem_ground
if drone < ground and drone <= prem_ground:
method = "Drone"
cost = drone
elif prem_ground < ground and prem_ground < drone:
method = "Premium Ground"
cost = prem_ground
elif ground < prem_ground and ground < drone:
method = "Ground"
cost = ground
return "You should ship using " + method + " it will cost " + cost
cheapest_shipping(17)
…
…
The second one just loads forever. The first one gives errors I don’t understand. Help??