CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day07/avgscore.py
Views: 729
1
"""
2
输入学生考试成绩计算平均分
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-06
7
"""
8
9
10
def main():
11
number = int(input('请输入学生人数: '))
12
names = [None] * number
13
scores = [None] * number
14
for index in range(len(names)):
15
names[index] = input('请输入第%d个学生的名字: ' % (index + 1))
16
scores[index] = float(input('请输入第%d个学生的成绩: ' % (index + 1)))
17
total = 0
18
for index in range(len(names)):
19
print('%s: %.1f分' % (names[index], scores[index]))
20
total += scores[index]
21
print('平均成绩是: %.1f分' % (total / number))
22
23
24
if __name__ == '__main__':
25
main()
26
27