统计我们班同学英语成绩各分数人数

统计我们班同学英语成绩各分数人数:
1.100分人数
2.大于等于90分小于100分人数
3.大于等于80分小于90分人数
4.大于等于70分小于80分人数
5.大于等于60分小于70分人数
6.小于60分人数


a = input().split()
a = [int(i) for i in a]
b = {}
for i in a:
    if i == 100:
        b["100"] = b.get("100",1)+1
    elif i >= 90:
        b["90"] = b.get("90",1)+1
    elif i >= 80:
        b["80"] = b.get("80",1)+1
    elif i >= 70:
        b["70"] = b.get("70",1)+1
    elif i >= 60:
        b["60"] = b.get("60",1)+1
    else:
        b["0"] = b.get("0",1)+1
print(b)

给个实现方案,仅供参考:

scores = [100,90,87,78,89,100,90,87,78,89,65,54,56,68]
scores100 = [s for s in scores if s==100]
scores90_100 = [s for s in scores if s<100 and s>=90]
scores80_90 = [s for s in scores if s<90 and s>=80]
scores70_80 = [s for s in scores if s<80 and s>=70]
scores60_70 = [s for s in scores if s<70 and s>=60]
scores60 = [s for s in scores if s<60]
print(scores100)
print(scores90_100)
print(scores80_90)
print(scores70_80)
print(scores60_70)
print(scores60)

img

numlist = [100,90,87,78,89]
a=0
b=0
c=0
d=0
for i in numlist:
    if i==100:
        a+=1
    elif i>=90:
        b+=1
    elif i>=80:
        c+=1
    elif i>=70:
        d+=1

如有用请采纳