-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath8_answer.py
43 lines (33 loc) · 1.13 KB
/
math8_answer.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
import math
# Length of face diagonal calculation
def len_of_face(x, y):
return math.sqrt(pow(x,2) + pow(y,2))
# Dimensions of box 1
length1 = 21
width1 = 16
height1 = 46
volume1 = length1 * width1 * height1
# Dimensions of box 2
length2 = 18
width2 = 22
height2 = 43
volume2 = length2 * width2 * height2
# Minimum and maximum volumes
min_volume = min(volume1, volume2)
max_volume = max(volume1, volume2)
# Maximum : minimum ratio
ratio = float(max_volume) / float(min_volume)
# Print the ratio, round to one decimal place
print "The ratio of max to min volume is " + format(ratio, ".1f")
# Box 1 length of face diagonal calculation
d_lw1 = len_of_face(length1, width1)
d_lh1 = len_of_face(length1, height1)
d_hw1 = len_of_face(height1, width1)
print "The lengths of face diagonals of box 1 are " + format(d_lw1, ".1f") + ", " + format(d_lh1, ".1f") + ", " + format(d_hw1, ".1f")
# Find the longest face diagonal length
if (d_lw1 >= d_lh1) and (d_lw1 >= d_hw1):
print "d_lw1 is the longest face diagonal"
elif (d_lh1 >= d_lw1) and (d_lh1 >= d_hw1):
print "d_lh1 is the longest face diagonal"
else:
print "d_hw1 is the longest face diagonal"