-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0320c.py
More file actions
33 lines (32 loc) · 859 Bytes
/
Copy path0320c.py
File metadata and controls
33 lines (32 loc) · 859 Bytes
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
f = open("bodyinfo.csv", "r", encoding="utf-8")
rawdata = f.readlines()
f.close()
data = [item.split(",") for item in rawdata[1:]]
heights = [int(d[1]) for d in data]
weights = [int(d[2]) for d in data]
bmis = [round(int(d[2]) / (int(d[1])/100)**2,2) for d in data]
'''
bmis = list()
for d in data:
w = int(d[2])
h = int(d[1])
bmi = w / (h/100)**2
bmis.append(round(bmi, 2))
'''
print(bmis)
print("本班最高的學生是{}公分".format(max(heights)))
print("本班最矮的學生是{}公分".format(min(heights)))
print("本班平均身高是{}公分".format(round(sum(heights)/len(heights)),2))
'''
names = list()
heights = list()
weights = list()
for item in rawdata:
name, height, weight = item.split(",")
names.append(name)
heights.append(height)
weights.append(weight)
'''
#print(names)
#print(heights)
#print(weights)