TQC+ 程式語言Python 607 成績計算
題目說明:
請撰寫一程式,讓使用者輸入三位學生各五筆成績,接著再計算並輸出每位學生的總分及平均分數。
提示:平均分數輸出到小數點後第二位。
輸入與輸出會交雜如下,輸出的部份以粗體字表示
The 1st student:
78
89
88
70
60
The 2nd student:
90
78
66
68
78
The 3rd student:
69
97
70
89
90
Student 1
#Sum 385
#Average 77.00
Student 2
#Sum 380
#Average 76.00
Student 3
#Sum 415
#Average 83.00
78
89
88
70
60
The 2nd student:
90
78
66
68
78
The 3rd student:
69
97
70
89
90
Student 1
#Sum 385
#Average 77.00
Student 2
#Sum 380
#Average 76.00
Student 3
#Sum 415
#Average 83.00
程式碼:
List = ['1st', '2nd', '3rd']
score = []
for i in range(3):
print('The %s student:' %List[i])
score.append([])
for j in range(5):
score[i].append(eval(input()))
for k in range(3):
print('Student %d' %(k + 1))
print('#Sum %d' %sum(score[k]))
print('#Average %.2f' %(sum(score[k]) / 5))
一個評論
自動引用通知: