Hello! I am currently working on the third project for the introduction to python and am getting the type error ‘‘float’ object is not callable’
I am not sure how to adjust my code. Also, the walkthrough uses strange syntax ‘%.2f’ and ‘% (cost)’ that I don’t understand.
Can someone please explain what is going on?
My Code:
#Ground shipping rates
def ground_rates(weight):
if weight <= 2:
cost = weight * 1.5 + 20
return cost
elif (weight > 2) and (weight <= 6):
cost = weight * 3 + 20
return cost
elif (weight > 6) and (weight <= 10):
cost = weight * 4 + 20
return cost
else:
cost = weight * 4.75 + 20
return cost
#Primium shipping flat rate
primium_ground_shipping = 125.00
#Drone rates
def drone_rates(weight):
if weight <= 2:
cost = weight * 4.50
return cost
elif (weight > 2) and (weight <= 6):
cost = weight * 9.00
return cost
elif (weight > 6) and (weight <= 10):
cost = weight * 12.00
return cost
else:
cost = weight * 14.25
return cost
#Best shipping option determiner
def best_option(weight):
if (primium_ground_shipping() < ground_rates()) and (primium_ground_shipping() < drone_rates()):
cost = 125.00
print(‘Go primium for $’ + str(cost))
elif (ground_rates() < primium_ground_shipping()) and (ground_rates() < drone_rates()):
cost = ground_rates()
print(‘Go ground for $’ + str(cost))
else:
cost = drone_rates()
print(‘Go drone for $’ +str(cost))
best_option(4.8)