我以前也问过类似的问题,所以我很抱歉,但是我把任务看回去了,并且误读了最初的要求。在
因此,根据我在这里收到的反馈,这是我使用的代码:def task3():
classList = {}
classSearch = input("Which class would you like to interrogate? ")
try:
with open("answers " + classSearch + ".txt", 'rb') as handle:
classList = pickle.loads(handle.read())
except IOError as error:
print ("Sorry, this file does not exist")
sortOption = int(input("Would you like sort the students in alphabetical order? Enter 1\n Would you like to sort the students by highest score? Enter 2 \nWould you like to sort students by their average score?Enter 3\n"))
if sortOption == 1:
x = sorted(classList.items())
for key, value in x:
value.sort()
value.reverse()
print (x)
所以我需要做的是输出每个学生的最高分数,按名字的字母顺序排序。在classList字典中是一个学生的名字,然后是一个包含他们在测验中得到的最后3个分数的列表。这显然是重复多个学生。任何帮助都将不胜感激。在
作者分享了一个用于处理学生班级成绩的任务代码。该代码读取特定班级的成绩数据,提供按字母顺序、最高分或平均分对学生进行排序的功能。作者请求帮助以完善代码实现。

2689

被折叠的 条评论
为什么被折叠?



