2.
list = [68, 75, 32, 99, 78, 45, 88, 72, 83, 78]
a = b = c = d = 0
for i in list:
if i in range(90, 100):
a += 1
elif i in range(80, 89):
b += 1
elif i in range(60, 79):
c += 1
else:
d += 1
print("等级为优的人数为:", a, "\n等级为良的人数为:", b, "\n等级为中的人数为:", c, "\n等级为差的人数为:", d)
4.
student = {
"a": 50, "g": 45,
"b": 45, "j": 45,
"q": 45, "n": 45,
"w": 45, "l": 45,
"e": 45, "m": 45,
}
def X(a):
sum = 0
for i in a.values():
sum += i
return sum / len(a)
print("学生姓名和成绩如下:")
print(student)
print("总人数为", len(student), "平均分为", X(student))