Python-100-Days/Day01-15/code/Day07/avgscore.py

26 lines
661 B
Python
Raw Normal View History

2018-04-27 00:00:22 +08:00
"""
输入学生考试成绩计算平均分
Version: 0.1
Author: 骆昊
Date: 2018-03-06
"""
def main():
2019-05-03 21:17:36 +08:00
number = int(input('请输入学生人数: '))
names = [None] * number
scores = [None] * number
for index in range(len(names)):
names[index] = input('请输入第%d个学生的名字: ' % (index + 1))
scores[index] = float(input('请输入第%d个学生的成绩: ' % (index + 1)))
total = 0
for index in range(len(names)):
print('%s: %.1f' % (names[index], scores[index]))
total += scores[index]
print('平均成绩是: %.1f' % (total / number))
2018-04-27 00:00:22 +08:00
if __name__ == '__main__':
2019-05-03 21:17:36 +08:00
main()