python跳高成绩统计
时间: 2023-12-13 21:34:29 浏览: 135
以下是一个Python跳高成绩统计的例子:
```python
# 定义分数段
score_ranges = ['90-100', '80-89', '70-79', '60-69', '0-59']
# 初始化分数段人数
score_counts = [0] * len(score_ranges)
# 初始化总人数
total_count = 0
# 初始化总分数
total_score = 0
# 初始化最高分和最低分
max_score = 0
min_score = 100
# 输入成绩
n = int(input())
for i in range(n):
score = int(input())
total_count += 1
total_score += score
if score > max_score:
max_score = score
if score < min_score:
min_score = score
for j in range(len(score_ranges)):
if score >= int(score_ranges[j].split('-')[0]) and score <= int(score_ranges[j].split('-')[1]):
score_counts[j] += 1
break
# 计算平均分
avg_score = total_score / total_count
# 输出结果
for i in range(len(score_ranges)):
print(f'{score_ranges[i]}: {score_counts[i]}, {score_counts[i] / total_count:.2%}')
print(f'Max score: {max_score}')
print(f'Min score: {min_score}')
print(f'Avg score: {avg_score:.1f}')
```
阅读全文