统计一个班级学生的考试成绩,首先需要录入学生及其考试成绩。选出最高分,平均分,分数由高到低进行排序。评出学霸和学渣!
我的代码如下:
#!/usr/bin/env python
#coding:utf-8
#352-01.py
a=1
n1=raw_input("please input number of student:")
n=int(n1)
dd={}
while a<=n:
i=raw_input("please input student name:")
j=raw_input("please input score for %s:"% i)
dd[i]=j
a+=1
print"it is the message you input",dd
def ave(x):
x1=x.values()
s6=0
for o in x1:
s6=s6+int(o)
x3=len(x1)
x4=s6/x3
return x4
def shunxu(x):
y1=[]
for k in x:
y2=(x[k],k)
y1.append(y2)
y3=sorted(y1,reverse=True)
y5=[]
for k1 in y3:
y4=(k1[1],k1[0])
y5.append(y4)
return y5
d

该博客展示了如何使用Python编程统计班级学生的考试成绩,包括输入学生姓名和分数,计算平均分,按分数降序排序,并找出最高分(学霸)和最低分(学渣)。作者分享了自己的代码并寻求优化建议。
最低0.47元/天 解锁文章

552

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



