Created
May 22, 2021 21:41
-
-
Save x1001000/63d862d522dac55a67cae8f6665d0ca6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
names, heights, weights = [], [], [] | |
with open('read.txt') as f: | |
for line in f.readlines(): | |
print(line) | |
name, height, weight = line.split() | |
names.append(name) | |
heights.append(float(height)) | |
weights.append(float(weight)) | |
n = len(names) # n個人 | |
H = max(heights)# 最高H | |
W = max(weights)# 最重W | |
print(f'Average height: {sum(heights)/n:.2f}') | |
print(f'Average weight: {sum(weights)/n:.2f}') | |
print(f'The tallest is {names[heights.index(H)]} with {H:.2f}cm') | |
print(f'The heaviest is {names[weights.index(W)]} with {W:.2f}kg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment