Skip to content

Instantly share code, notes, and snippets.

@FateEvent
Created September 11, 2021 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FateEvent/df3077ad5826054d865cddfc3b8dc21f to your computer and use it in GitHub Desktop.
Save FateEvent/df3077ad5826054d865cddfc3b8dc21f to your computer and use it in GitHub Desktop.

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