-
Notifications
You must be signed in to change notification settings - Fork 0
/
function-if-Py-project
78 lines (59 loc) · 1.46 KB
/
function-if-Py-project
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
def ground_ship(weight):
if weight <=2:
cost= weight*1.5 +20
return cost
elif weight>2 and weight <=6:
cost = weight*3.0 +20
return cost
elif weight>6 and weight <=10:
cost = weight*4.0 +20
return cost
else:
cost = weight*4.75 +20
return cost
print(ground_ship(8.4))
def Premium_ship(weight):
if weight ==weight:
return 125
premium = 125
print(Premium_ship(5))
def drone_ship(weight):
if weight <=2:
per_weight = 4.5
elif weight>2 and weight <=6:
per_weight = 9
elif weight>6 and weight <=10:
per_weight = 12
else:
per_weight = 14.25
return weight*per_weight
print(drone_ship(1.5))
def cheapest(weight):
ground = ground_ship(weight)
drone = drone_ship(weight)
global premium
if ground < drone and ground <premium:
print('ground the cheapest', ground)
elif drone <ground and drone <premium:
print('drone the cheapest', drone)
else:
return ('premium cheapeast','for',weight,'lb', premium, '$')
print(cheapest(4.8))
print(cheapest(41.5))
#other:
def cheapest2(weight):
ground = ground_ship(weight)
drone = drone_ship(weight)
global premium
if ground < drone and ground <premium:
method = 'ground'
cost=ground
elif drone <ground and drone <premium:
method ='drone'
cost=drone
else:
method = 'premium'
cost = premium
print('the cheapest is $%.2f with %s shipping'%(cost,method))
cheapest2(4.8)
cheapest2(41.5)