Jun-11-2020, 02:45 AM
def ground_shipping_cost(weight): if (weight <= 2): # 2 pounds or less price = 1.50 elif (weight > 2) or (weight <= 6): price = 3.00 elif (weight > 6) or (weight <= 10): price = 4.00 elif (weight > 10): price = 4.75 cost = ((weight * price) + 20) return cost def drone_shipping_cost(weight): if (weight < 2): price = 4.50 elif (weight > 2) or (weight <= 6): price = 9.00 elif (weight > 6) or (weight <= 10): price = 12 elif (weight > 10): price = 14.25 return price premium_ground_shipping = 125.00 def cheapest_shipping (weight): if drone_shipping_cost(weight) < ground_shipping_cost (weight): ret = drone_shipping_cost(weight) ship_method = 1 # "ground shipping" elif ground_shipping_cost (weight) < drone_shipping_cost(weight): ret = ground_shipping_cost (weight) ship_method = 2 # "drone shipping" else: ret = premium_ground_shipping ship_method = 3 # "premium shipping return ret if (ship_method == 1): print_string == "ground_shipping" elif (ship_method == 2): print_string == "drone shipping" elif(ship_method == 3): print_string == "premium shipping" ship_price = cheapest_shipping (4.8) # input weight to calculate t_string = "You should ship using: " + str(print_string) + " it will cost " + str(ship_price) print(t_string)please can someone fix this line
t_string = "You should ship using: " + str(print_string) + " it will cost " + str(ship_price)I'm a noob coming from C and would like this script to work. I see that the str() function is working for the str(ship_price) successfully because I have used it for the cheapest_shipping (4.8) function, how do I get around doing that. Thanks!