Skip to content

Instantly share code, notes, and snippets.

@Celia-code
Last active April 16, 2020 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Celia-code/d0388d87224e4243ca2097a53da10b14 to your computer and use it in GitHub Desktop.
Save Celia-code/d0388d87224e4243ca2097a53da10b14 to your computer and use it in GitHub Desktop.
CH1總結
student_list = []
total = 0
while True:
name = input("請輸入學生名【輸入Enter即退出程序】:")
if name == '':
print('結束程序')
break
else:
while True:
score = int(input("請輸入學生成績:"))
if score >= 0:
total += score
break
print('輸入成績有誤,請重新輸入')
student_list.append([name, score])
print("===========================")
print('1. 學生成績:')
for i in range(1, len(student_list) + 1):
print(' (%s)' % i, 'name: %-5s' % student_list[i - 1][0], 'score: %-5s' % student_list[i - 1][1])
print('2. 學生總數:{}'.format(len(student_list)))
average = total / (len(student_list))
print('3. 班平均:{}'.format(average))
print(' → 該班平均及格' if average >= 60 else ' → 該班平均未及格')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment