# scores=[]
# for i in range(5):
# keys = ['name', 'english', 'python', 'math']
# strstu = input("请输入学生姓名,english,python,math三个科目的成绩分别以空格隔开:\n")
# ls = strstu.split(" ")
# dictionary = dict(zip(keys, ls))
# scores.append(dictionary)
scores = [{'name': 'hahah', 'english': '11', 'python': '22', 'math': '33'}, {'name': 'hh', 'english': '33', 'python': '33', 'math': '33'}, {'name': 'kk', 'english': '22', 'python': '22', 'math': '33'}, {'name': 'll', 'english': '33', 'python': '33', 'math': '11'}, {'name': 'll', 'english': '33', 'python': '33', 'math': '11'}]
for score in scores:
score['avg'] = (int(score['english']) + int(score['python']) + int(score['math']))/3
scores = sorted(scores, key=lambda x:x['avg'])
for score in scores:
print(f'学生{score["name"]}的平均分数为{score["avg"]}')
print('英语不及格的同学为:')
for score in scores:
if int(score['english']) < 60:
print(score['name'])
print('python不及格的同学为:')
for score in scores:
if int(score['python']) < 60:
print(score['name'])
print(f'数学不及格的同学为:')
for score in scores:
if int(score['math']) < 60:
print(score['name'])
问题解决的话记得点击一下采纳谢谢