这是题目
这是我的代码
这是运行结果
我想知道怎么改正呢?还有怎么求最大和最小值,谢谢
# -*- coding: utf-8 -*-
"""
@Project : CSDN问答
@Software: PyCharm
@File : 3-输入10名学生的名字和成绩.py
@Author : mlnt_zzy
@Time : 2022/11/20 17:32
"""
"""
输入全班10名学生的名字和成绩,生成字典后输出(键为学生姓名,值为学生成绩),
并输出其中最高分和最低分及全班同学的平均分,要求利用字典实现。
"""
student_score = {"zhang1": "90", "zhang2": "88", "zhang3": "86", "zhang4": "78",
"zhang5": "81", "zhang6": "80", "zhang7": "78", "zhang8": "96",
"zhang9": "83", "zhang10": "82", }
print("包含学生姓名和分数的字典为:", student_score)
sumscore = 0
maxscore = 0
minscore = 0
list_score = list(map(int, student_score.values()))
# print(list_score)
maxscore = max(list_score)
minscore = min(list_score)
# print(maxscore)
# print(minscore)
sumscore = sum(list_score)
avrscore = sumscore / len(student_score.values())
print("最高分为:", maxscore, "最低分为:", minscore, "平均分为:", str(sumscore/10))
# 最高分为: 96 最低分为: 78 平均分为: 84.2