|
| 1 | +def ground_shipping(weight): |
| 2 | + flat_charge = 20 |
| 3 | + if (weight <= 2): |
| 4 | + price = weight * 1.50 |
| 5 | + return price + flat_charge |
| 6 | + elif (weight > 2) and (weight <= 6): |
| 7 | + price = weight * 3.00 |
| 8 | + return price + flat_charge |
| 9 | + elif (weight > 6) and (weight <= 10): |
| 10 | + price = weight * 4.00 |
| 11 | + return price + flat_charge |
| 12 | + elif (weight > 10): |
| 13 | + price = weight * 4.75 |
| 14 | + return price + flat_charge |
| 15 | + |
| 16 | +premium_ground_shipping = 125.00 |
| 17 | + |
| 18 | +def drone_shipping(weight): |
| 19 | + if (weight <= 2): |
| 20 | + price = weight * 4.50 |
| 21 | + return price |
| 22 | + elif (weight > 2) and (weight <= 6): |
| 23 | + price = weight * 9.00 |
| 24 | + return price |
| 25 | + elif (weight > 6) and (weight <= 10): |
| 26 | + price = weight * 12.00 |
| 27 | + return price |
| 28 | + elif (weight > 10): |
| 29 | + price = weight * 14.75 |
| 30 | + return price |
| 31 | + |
| 32 | +# Recommendation function |
| 33 | +def cheapest_shipping(weight): |
| 34 | + if (drone_shipping(weight) < premium_ground_shipping) and (drone_shipping(weight) < ground_shipping(weight)): |
| 35 | + price = drone_shipping(weight) |
| 36 | + return "Dear, your Cheapest Shipping - Drone Shippping & price: " + str(price) + "$" |
| 37 | + elif (drone_shipping(weight) > premium_ground_shipping) and (premium_ground_shipping < ground_shipping(weight)): |
| 38 | + price = premium_ground_shipping |
| 39 | + return "Dear, your Cheapest Shipping - Premium Ground Shipping & price: " + str(price) + "$" |
| 40 | + elif (drone_shipping(weight) > ground_shipping(weight)) and (premium_ground_shipping > ground_shipping(weight)): |
| 41 | + price = ground_shipping(weight) |
| 42 | + return "Dear, your Cheapest Shipping - Ground Shipping price: " + str(price) + "$" |
| 43 | + |
| 44 | + |
| 45 | +#Code testing |
| 46 | +print(cheapest_shipping(4.8)) |
| 47 | + |
| 48 | +print(cheapest_shipping(41.5)) |
0 commit comments