-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsal_ship.py
More file actions
88 lines (80 loc) · 3.89 KB
/
sal_ship.py
File metadata and controls
88 lines (80 loc) · 3.89 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
def gnd_ship(pack_wht):
if (pack_wht <= 2):
price = 1.5 * pack_wht + 20
elif (pack_wht > 2) and (pack_wht <=6):
price = 3 * pack_wht + 20
elif (pack_wht > 6) and (pack_wht <= 10):
price = 4 * pack_wht + 20
elif (pack_wht > 10):
price = 4.75 * pack_wht + 20
price = round(price,2)
return price
def drone_ship(pack_wht):
if (pack_wht <= 2):
price = 4.5 * pack_wht
elif (pack_wht > 2) and (pack_wht <=6):
price = 9 * pack_wht
elif (pack_wht > 6) and (pack_wht <= 10):
price = 12 * pack_wht
elif (pack_wht > 10):
price = 14.25 * pack_lbs
price = round(price, 2)
return price
def gnd_ship_prem(pack_wht):
price = 125
return price
pack_lbs = float(input("Package weight?"))
gnd_price = gnd_ship(pack_lbs)
drone_price = drone_ship(pack_lbs)
prem_price = gnd_ship_prem(pack_lbs)
print("Ground Shipping price is: $" + str(gnd_price))
print("Drone Shipping price is $" + str(drone_price))
print("Premium Ground Shipping price is $" + str(prem_price))
def find_method(option1, option2, price):
method = input("Which method you like to choose?" + " (" + option1.title() + "/ " + option2.title() + ")").lower()
if method == option1:
msg_2 = "You chose " + option1.title() + ". It will cost $" + str(price) + " to ship " + str(pack_lbs)+ " pounds."
elif method == option2:
msg_2 = "You chose " + option2.title() + ". It will cost $" + str(price) + " to ship " + str(pack_lbs)+ " pounds."
else:
print("Invalid Entry. Must enter either " + option1.title() + " or " + option2.title() + ". Try again.")
msg_2 = find_method(option1, option2, price)
return msg_2
def print_msg():
if (gnd_price < drone_price) and (gnd_price < prem_price):
msg = "Ground Shipping is the cheapest option. It will cost $" + str(gnd_price) + " to ship " + str(pack_lbs) + " pounds."
elif (drone_price < gnd_price) and (drone_price < prem_price):
msg = "Drone Shipping is the cheapest option. It will cost $" + str(drone_price) + " to ship " + str(pack_lbs) + " pounds."
elif (prem_price < drone_price) and (prem_price < gnd_price):
msg = "Premium Ground Shipping is the cheapest option. It will cost $" + str(prem_price) + " to ship " + str(pack_lbs) + " pounds."
elif (prem_price == drone_price) or (prem_price == gnd_price):
if drone_price < gnd_price:
msg = "Premium Ground Shipping Price is the same as Drone Shipping Price"
print(msg)
msg_3 = find_method('premium ground', 'drone shipping',prem_price)
elif gnd_price < drone_price:
msg = "Premium Ground Shipping Price is the same as Ground Shipping Price."
print(msg)
msg_3 = find_method('premium ground shipping','ground shipping',prem_price)
return msg_3
elif (drone_price == prem_price) or (drone_price == gnd_price):
if prem_price < gnd_price:
msg = "Drone Shipping Price is the same as Premium Ground Shipping Price."
print(msg)
msg_3 = find_method('drone shipping','premium ground shipping',drone_price)
elif gnd_price < prem_price:
msg = "Drone Shipping Price is the same as Ground Shipping Price."
print(msg)
msg_3 = find_method('drone shipping','ground shipping',drone_price)
elif (gnd_price == prem_price) or (gnd_price == drone_price):
if prem_price < drone_price:
msg = "Ground Shipping price is the same as Premium Ground Shipping Price"
print(msg)
msg_3 = find_method('ground shipping','premium ground shipping',gnd_price)
elif drone_price < prem_price:
msg = "Ground Shipping price is the same as Drone Shipping price."
print(msg)
msg_3 = find_method('ground shipping','drone shipping',gnd_price)
return msg_3
return msg
print(print_msg())