7-40 jmu-python- statistical score (15 points)

Enter the number of student achievement, grade point average is calculated, and the statistical number of students failing.

Input formats:

Each line of input data, the input data is the 负数end of the input

Output formats:

平均分=XX,不及格人数=XXWhich XXindicates that the corresponding data. If there is no student data, output没有学生

Sample input:

30
50
70
80
90
20
-1

Sample output:

平均分=56.67,不及格人数=3
a = float(input())
list = []
sum = a
list.append(a)
count = 1
if a >= 0:
    while 1:
        a = float(input())
        if a < 0:
            break
        list.append(a)
        sum = a + sum
        count = count + 1
    print("平均分={:.2f},不及格人数=".format(sum / count), end="")
    n = 0
    for i in list:
        if i < (sum / count):
            n = n + 1
    print("%d" % n)
else :
    print("没有学生")

  

Guess you like

Origin www.cnblogs.com/aimilu/p/11819138.html