-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshipping.py
54 lines (40 loc) · 1.13 KB
/
shipping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def shipping_cost_ground(weight):
# Ground shipping
if weight <= 2:
price_per_pound = 1.50
elif weight <= 6:
price_per_pound = 3.00
elif weight <= 10:
price_per_pound = 4.00
else:
price_per_pound = 4.75
return 20 + (price_per_pound * weight)
print(shipping_cost_ground(8.4))
shipping_cost_premium = 125.00
def shipping_cost_drone(weight):
if weight <= 2:
price_per_pound = 4.50
elif weight <= 6:
price_per_pound = 9.00
elif weight <= 10:
price_per_pound = 12.00
else:
price_per_pound = 14.25
return price_per_pound * weight
print(shipping_cost_drone(1.5))
def print_cheapest_shipping_method(weight):
ground = shipping_cost_ground(weight)
premium = shipping_cost_premium
drone = shipping_cost_drone(weight)
if ground < premium and ground < drone:
method = "standard ground"
cost = ground
elif premium < ground and premium < drone:
method = "premium"
cost = premium
else:
method = "drone"
cost = drone
print("The cheapest option available is $%.2f with %s shipping." % (cost, method))
print_cheapest_shipping_method(4.8)
print_cheapest_shipping_method(41.5)