[Python] 纯文本查看 复制代码 scores=input().split(',')
relist=sorted(scores,reverse=True)
output=[]
l=len(relist)
sum=0
fail=grade6=grade7=grade8=grade9=0
for i in relist:
i=int(i)
output.append(i)
sum+=i
if i >=90:
grade9+=1
elif i>=80:
grade8+=1
elif i>=70:
grade7+=1
elif i>=60:
grade6+=1
else:
fail+=1
print('平均成绩:{:.1f}'.format(sum/l))
print('60分以下{0}人,占总人数的{1:.1f}%'.format(fail,fail/l*100))
print('69到60分{0}人,占总人数的{1:.1f}%'.format(grade6,grade6/l*100))
print('79到70分{0}人,占总人数的{1:.1f}%'.format(grade7,grade7/l*100))
print('89到80分{0}人,占总人数的{1:.1f}%'.format(grade8,grade8/l*100))
print('99到90分{0}人,占总人数的{1:.1f}%'.format(grade9,grade9/l*100))
print('本课程成绩',output,sep=':') |