1. 綜合使用 list、dict、函式
2. 使用迴圈與條件判斷
專題需求:
- 存學生資料
- 計算平均分數
students = [
{"name": "Amy", "score": 90},
{"name": "John", "score": 80}
]
# 印出學生
for s in students:
print(s["name"], s["score"])
# 計算平均
total = 0
for s in students:
total += s["score"]
avg = total / len(students)
print("平均分數:", avg)
1. 新增一位學生資料
2. 修改某位學生分數
3. 計算所有學生平均分數
4. 嘗試排序學生分數
✔ 綜合使用 list、dict、函式
✔ 使用迴圈與條件