Python 2.7 (Learnt)

def ground_cost(weight):
  if weight <= 2:
    return weight * 1.50 + 20
  elif weight > 2 and weight <= 6:
    return weight * 3.00 + 20
  elif weight > 6 and weight <= 10:
    return weight * 4.00 + 20
  elif weight > 10:
    return weight * 4.75 + 20

premground_cost = 125.0

def drone_cost(weight):
  if weight <= 2:
    return weight * 4.50
  elif weight > 2 and weight <= 6:
    return weight * 9
  elif weight > 6 and weight <= 10:
    return weight * 12
  elif weight > 10:
    return weight * 14.25


def pricecheck(weight):
  if ground_cost(weight) < premground_cost and ground_cost(weight) < drone_cost(weight):
    return "Ground shipping is the cheapest option for the selected weight. Your total cost will be $" + str(ground_cost(weight)) + "."
  elif premground_cost < ground_cost(weight) and premground_cost < drone_cost(weight):
    return "Our premium option is for you. The total price is set at 125 dollars."
  elif drone_cost(weight) < ground_cost(weight) and drone_cost(weight) < premground_cost:
    return "Drone shipping seems to be the cheapest for you! Your cost will be $" + str(drone_cost(weight)) + "."

Similiar Collections