import random names = ['关羽','张飞','赵云','马超','黄忠'] courses = ['语文','数学','英语'] scores = [[random.randrange(60,101) for _ in range(3)] for _ in range(5)] from statistics import mean for i, name in __________(names): print(f'{name}的平均分:{mean(scores[i]):.1f}分') from statistics import stdev for j, ________ in enumerate(________): temp = [______________] print(f'{course}的最高分:{max(temp)}分') print(f'{course}的最低分:{min(temp)}分') print(f'{course}的标准差:{stdev(temp)}分') scores_dict = {__________: __________ for i in range(len(names))} sorted_keys = sorted(scores_dict, key=lambda k: ___(scores_dict[k]), reverse=____) print('姓名\t语文\t数学\t外语') for ______ in sorted_keys: verbal, math, english = scores_dict[key] print(f'{key}\t{verbal}\t{math}\t{english}')
时间: 2024-01-22 13:03:18 浏览: 92
Graduate-courses--papers.zip_K._方程离散化_离散数学模型
1. 填入代码:
```python
enumerate(names)
```
2. 填入代码:
```python
course, scores, courses
```
3. 填入代码:
```python
names[i], scores[i], key, lambda k: mean(scores_dict[k]), True
```
完整代码如下:
```python
import random
from statistics import mean, stdev
names = ['关羽','张飞','赵云','马超','黄忠']
courses = ['语文','数学','英语']
scores = [[random.randrange(60,101) for _ in range(3)] for _ in range(5)]
for i, name in enumerate(names):
print(f'{name}的平均分:{mean(scores[i]):.1f}分')
for j, course in enumerate(courses):
temp = [scores[i][j] for i in range(len(names))]
print(f'{course}的最高分:{max(temp)}分')
print(f'{course}的最低分:{min(temp)}分')
print(f'{course}的标准差:{stdev(temp):.1f}分')
scores_dict = {names[i]: scores[i] for i in range(len(names))}
sorted_keys = sorted(scores_dict, key=lambda k: mean(scores_dict[k]), reverse=True)
print('姓名\t语文\t数学\t外语')
for key in sorted_keys:
verbal, math, english = scores_dict[key]
print(f'{key}\t{verbal}\t{math}\t{english}')
```
阅读全文