import random
import string
list_index=["名次","學號","姓名","語文","數(shù)學","英語","總分","均分"] #定義字段名
list_name=["趙云","關(guān)羽","張飛","黃忠","馬超","張三","李四","李五","趙四","蘇蘇"] #定義名字
list_num=[]
dict_num={}
for i in range(0,len(list_name)):
T=[]
for j in range(0,3):
T.append(random.randint(50,100))
T.append(sum(T))
T.append(T[-1]/len(T))
T.insert(0,list_name[i])
T.insert(0,2000+i)
list_num.append(list(T))
T.clear()
list_num=sorted(list_num,key=(lambda x:x[6]))
list_num.reverse()
for i in range(0,len(list_name)):
dict_num[str(i+1)]=list_num[i]
print("成績統(tǒng)計表".center(54,"#"))
print(str(list_index[0]).center(6),end=" ")
for j in range(1,8): #循環(huán)輸出所有字段名
print(list_index[j].center(5),end=" ")
print()
print("="*57)
for i,j in dict_num.items():
print(str(i).center(8),end=" ")
for x in j:
print(str(x).center(6),end=" ")
print()
print("="*57)