Untitled
unknown
plain_text
2 years ago
482 B
12
Indexable
g_list = []
while True:
n = input('請輸入學生分數(輸入w退出): ')
if n == 'w':
print('謝謝填寫')
break
else:
score = int(n)
g_list.append(score)
print(f"已加入 {score}")
if len(g_list) > 0:
total_scores = sum(g_list)
average_score = total_scores / len(g_list)
print(f"您共輸入了{len(g_list)}科的成績,您的平均成績為{average_score:.1f}")
else:
print("沒有輸入任何成績。")Editor is loading...
Leave a Comment