Skip to content

Instantly share code, notes, and snippets.

@FateEvent
Created Sep 11, 2021
Embed
What would you like to do?

My rendering of a Codecademy project with Python.

# Sal's Shipping
shipping_method = "Ground Shipping"
weight = 4.8
flat_charge = 20.00
premium_flat_charge = 125.00
# Ground Shipping
if shipping_method == "Ground Shipping" and weight <= 2:
cost = weight * 1.50 + flat_charge
print("The price of the Ground Shipping for a weight of " + str(weight) + " lb is $" + str(cost) + ".")
elif shipping_method == "Ground Shipping" and weight <= 6:
cost = weight * 3.00 + flat_charge
print("The price of the Ground Shipping for a weight of " + str(weight) + " lb is $" + str(cost) + ".")
elif shipping_method == "Ground Shipping" and weight <= 10:
cost = weight * 4.00 + flat_charge
print("The price of the Ground Shipping for a weight of " + str(weight) + " lb is $" + str(cost) + ".")
elif shipping_method == "Ground Shipping" and weight > 10:
cost = weight * 4.75 + flat_charge
print("The price of the Ground Shipping for a weight of " + str(weight) + " lb is $" + str(cost) + ".")
# Ground Shipping Premium
elif shipping_method == "Premium Ground Shipping":
print("The price of the Premium Ground Shipping is $" + str(premium_flat_charge) + ", regardless of the weight of your package.")
# Drone Shipping
elif shipping_method == "Drone Shipping" and weight <= 2:
cost = weight * 4.50
print("The price of the Drone Shipping for a weight of " + str(weight) + " lb is $" + str(cost) + ".")
elif shipping_method == "Drone Shipping" and weight <= 6:
cost = weight * 9.00
print("The price of the Drone Shipping for a weight of " + str(weight) + " lb is $" + str(cost) + ".")
elif shipping_method == "Drone Shipping" and weight <= 10:
cost = weight * 12.00
print("The price of the Drone Shipping for a weight of " + str(weight) + " lb is $" + str(cost) + ".")
elif shipping_method == "Drone Shipping" and weight > 10:
cost = weight * 14.25
print("The price of the Drone Shipping for a weight of " + str(weight) + " lb is $" + str(cost) + ".")
else:
print("Please enter one of our available shipping methods: Ground Shipping, Premium Ground Shipping or Drone Shipping. Pay attention to capitalization.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment