在这个代码的基础上怎么完成后面几点呢?(语言-python)

(1)请使用上述结构输入5个学生的name及3门课的成绩并存储到列表scores中。

(2)计算每位同学的平均成绩,同时在字典中添加关键字“avg”用来表示平均成绩。

(3)按照每个学生的平均成绩由高到低排序输出5个学生的相关信息。

(4)遍历列表scores,将每门课不及格的学生名单进行打印。

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)
print(scores)

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))
    dictionary['avg']=round((int(dictionary['english'])+int(dictionary['python'])+int(dictionary['math']))/3,1)
    scores.append(dictionary)
scores.sort(key=lambda x:x['avg'],reverse=True)
for i in scores:
    print(i)
print("不及格:")
for i in scores:
    if int(i['english'])<60:
        print('英语不及格:',i)
    if int(i['python'])<60:
        print('python不及格:',i)
    if int(i['math'])<60:
        print('数学不及格:',i)

# 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'])

问题解决的话记得点击一下采纳谢谢