Sal's Shipping Project

I’m proud of this one! In the tips at the end, it asked “Which is the cheapest option” and I thought “Why don’t I code this so it will tell me the cheapest option” and so I did. Here is my full Sal’s Shipping Project Code:

weight = 4.8
# Ground Shipping

if weight <= 2:
  cost_ground = weight * 1.5 + 20
elif weight <= 6:
  cost_ground = weight * 3.0 + 20
elif weight <= 10:
  cost_ground = weight * 4.0 + 20
else:
  cost_ground = weight * 4.75 + 20

cost_ground = "{:.2f}".format(cost_ground)
print("Ground Shipping Price: $" + str(cost_ground))

cost_premium = 125

print("Premium Shipping Price: $" + str(cost_premium))

# Drone Shipping

if weight <= 2:
  cost_drone = weight * 4.5
elif weight <= 6:
  cost_drone = weight * 9
elif weight <= 10:
  cost_drone = weight * 12
else:
  cost_drone = weight * 14.25

cost_drone = "{:.2f}".format(cost_drone)
print("Drone Shipping Price: $" + str(cost_drone) + "\n")

cost_ground = float(cost_ground)
cost_premium = int(cost_premium)
cost_drone = float(cost_drone)

if cost_ground < cost_premium and cost_ground < cost_drone:
  print("Ground Shipping is the cheapest option.")
elif cost_premium < cost_ground and cost_premium < cost_drone: 
  print("Premium Shipping is the cheapest option.")
elif cost_drone < cost_ground and cost_drone < cost_premium:
  print("Drone Shipping is the cheapest option.")
else:
  print("It is your choice to make.")
2 Likes

Thanks for posting this! I was trying to do the same thing but I my boolean statements weren’t working–I figured out what i did wrong thanks to this.

I like that code, it is pretty neat!

This is my code for Sal’s Shipping!

weight = 8.5
print("Sal's Shipping:")
print("Shipping for Less!")
print(" ")

#Ground Shipping
if weight <= 2:
  ground_cost = weight*1.5+20
elif weight <= 6:
  ground_cost = weight*3+20
elif weight <= 10:
  ground_cost = weight*4+20
else:
  ground_cost = weight*4.75+20

cost_premium = 125.00
print("The Cost of Ground Shipping Premium is ",cost_premium)

#Drone Shipping
if weight <= 2:
  dronecost = weight*4.50
elif weight <= 6:
  dronecost = weight*9.00
elif weight <= 10:
  dronecost = weight*12.00
else:
  dronecost = weight*14.25
print(" ")
print("While the cost of Ground Shipping is ",ground_cost)
print(" ")
print("And the cost of drone shipping is ",dronecost)
print("-----------------------------------------------")
print(" ")
cheapest = min(ground_cost,dronecost,cost_premium)

if cheapest == ground_cost:
  print("So, The Cheapest way to ship is by using Ground Shipping.")
elif cheapest == cost_premium:
  print("So, The Cheapest way to ship is by using Ground Shipping Premium.")
else:
  print("So, The Cheapest way to ship is by using Drone Shipping.")
print(" ")
print("Thank you for shipping with Sal's Shipping!")