-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShipping.py
More file actions
62 lines (46 loc) · 1.44 KB
/
Shipping.py
File metadata and controls
62 lines (46 loc) · 1.44 KB
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
55
56
57
58
59
60
61
62
def ground_shipping(weight):
if weight > 10:
return 4.75 * weight + 20
elif weight > 6:
return 4.00 * weight + 20
elif weight > 2:
return 3.00 * weight + 20
else:
return 2.5 * weight + 20
def premium_shipping():
return 125
def drone_shipping(weight):
if weight > 10:
return 14.25 * weight
elif weight > 6:
return 12 * weight
elif weight > 2:
return 9 * weight
else:
return 4.5 * weight
def get_cheapest(weight):
ground = ground_shipping(weight)
premium = premium_shipping()
drone = drone_shipping(weight)
if ground < premium and ground < drone:
return "Ground is cheapest"
elif premium < ground and premium < drone:
return "Premium is cheapest"
elif drone < premium and drone < ground:
return "Drone is cheapest"
else:
return "Some of the price values are the same"
weight_user = input("Enter the weight of your package. ")
while True:
try:
weight_convert = float(weight_user)
except ValueError:
print("Please enter a valid value")
weight_user = input("Enter the weight of your package. ")
else:
break
print("Ground Shipping Cost: ", ground_shipping(weight_convert))
print("Premium Shipping Cost: ", premium_shipping())
print("Drone Shipping Cost: ", drone_shipping(weight_convert))
print(get_cheapest(weight_convert))
print(isinstance(weight_user, float))