"李剛": 93,
"陳靜": 78,
"張金柱": 88,
"趙啟山": 91,
"李鑫": 65,
"黃寧": 83
}
sorted_scores = sorted(scores.items(), key=lambda x: x[1], reverse=True)
for item in sorted_scores:
print(item[0], end=" ")
運行結果為:李剛 趙啟山 張金柱 黃寧 陳靜 李鑫
該程序使用字典來存儲考生姓名和對應的成績,然後使用sorted函數對字典按照成績進行降序排序。最後通過循環遍歷排序後的結果,打印考生姓名。