Skip to content

Instantly share code, notes, and snippets.

@x1001000
Created May 22, 2021 21:41
Show Gist options
  • Save x1001000/63d862d522dac55a67cae8f6665d0ca6 to your computer and use it in GitHub Desktop.
Save x1001000/63d862d522dac55a67cae8f6665d0ca6 to your computer and use it in GitHub Desktop.
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