有/5个学生,每个学生的信息包招学号、姓名、3门课的成绩,从键盘输入/5个学生数张,要求打印出最高分的学生信息(学号、姓名、3门课成绩)
时间: 2024-06-14 18:05:36 浏览: 33
以下是一个示例代码,用于从键盘输入5个学生的信息,并打印出最高分的学生信息(学号、姓名、3门课成绩):
```python
# 定义一个包含学生信息的顺序表
students = []
# 输入学生信息
for i in range(5):
student = {}
student['学号'] = input('请输入学号:')
student['姓名'] = input('请输入姓名:')
student['成绩1'] = float(input('请输入第一门课的成绩:'))
student['成绩2'] = float(input('请输入第二门课的成绩:'))
student['成绩3'] = float(input('请输入第三门课的成绩:'))
students.append(student)
# 找到最高分的学生
max_score = 0
max_student = {}
for student in students:
total_score = student['成绩1'] + student['成绩2'] + student['成绩3']
if total_score > max_score:
max_score = total_score
max_student = student
# 打印最高分的学生信息
print('最高分的学生信息:')
print('学号:', max_student['学号'])
print('姓名:', max_student['姓名'])
print('成绩1:', max_student['成绩1'])
print('成绩2:', max_student['成绩2'])
print('成绩3:', max_student['成绩3'])
```
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)