alright so i’ve been working on the practices that the python 3 course has been giving me and i reached a point where the codes got a little too long.
i was wondering if there is any way to shorten the #BEST AND MOST COST EFFICIENT WAY OF SHIPPING code right at the end.
weight = int(input("weight of package in Lbs : "))
#GROUND SHIPPING
cost_ground = 0
if weight <= 2:
cost_ground = weight * 1.50 + 20
elif 2 < weight <= 6:
cost_ground = weight * 3 + 20
elif 6 < weight <= 10:
cost_ground = weight * 4 + 20
elif weight > 10:
cost_ground = weight * 4.75 + 20
print(f"\ncost of normal ground shipping for the {weight} Lbs package : {cost_ground}")
#DRONE SHIPPING
cost_drone = 0
if weight <= 2:
cost_drone = weight * 4.50
elif 2 < weight <= 6:
cost_drone = weight * 9
elif 6 < weight <= 10:
cost_drone = weight * 12
elif weight > 10:
cost_drone = weight * 14.25
print(f"\ncost of drone shipping for the {weight} Lbs package : {cost_drone}")
#PREMIUM GROUND SHIPPING
cost_premium_ground = 125
print(f"\noverall cost of premium ground shipping : {cost_premium_ground}")
#MINIMUM COST OF SHIPPING
minimum_cost = min(cost_ground, cost_premium_ground, cost_drone)
print(f"\nlowest price of shipping : {minimum_cost}")
#BEST AND MOST COST EFFICIENT WAY OF SHIPPING
if min(cost_ground, cost_premium_ground, cost_drone) == cost_ground:
print(f"the most cost efficient method of shipping for your package would be through ground shipping with the low cost of {cost_ground}!")
elif min(cost_ground, cost_premium_ground, cost_drone) == cost_drone:
print(f"the most cost efficient method of shipping for your package would be through drone shipping with the low cost of {cost_drone}!")
elif min(cost_ground, cost_premium_ground, cost_drone) == cost_premium_ground:
print(f"the most cost efficient method of shipping for your package would be through premium ground shipping with the low price of {cost_premium_ground}!")