Python 编程:筛选总分高于指定分数的学生姓名
dic={ 'Tommy':[92,90,100], 'Joyce':[99,100], 'Dora':[100,98,95,99], 'Akili':[100,99,100,98,99], 'Alisa':[98,98,97] } score=int(input()) #输入分数 lst=[] #创建空列表 for name,scores in dic.items(): #遍历字典 if sum(scores)>score: #判断当前学生的总分是否高于用户输入的分数 lst.append(name) #将符合条件的当前学生的姓名添加至列表lst中 lst.sort() #对列表进行排序 for name in lst: #遍历列表 print(name) #输出姓名
原文地址: https://www.cveoy.top/t/topic/ovZh 著作权归作者所有。请勿转载和采集!