7-1 jmu-python-异常-学生成绩处理基本版 (15分)

7-1 jmu-python-异常-学生成绩处理基本版 (15分)_第1张图片

n = int(input())
s = 0
cnt = 0
for i in range(n):
    try:
        x = input()
        x = int(x)
        s += x
        cnt += 1
        pass
    except:
        print('Error for data "{}"! Break'.format(x))
        break

if cnt == n:
    print('All OK')
    print('avg grade = %.2f'%(s/n))
print('Process Completed')

 

你可能感兴趣的:(PTA作业,python)