足球隊記著每個隊員的 (進球, 場數):{名字: (進球, 場數)}。寫 goals_per_game(record),返回 {名字: 平均每場進球},用 round(..., 1) 保留一位小數。還沒上過場的(場數是 0)算 0.0。
goals_per_game({"Mia": (10, 3), "Leo": (2, 0)})→{'Mia': 3.3, 'Leo': 0.0}goals_per_game({})→{}def goals_per_game(record):
result = {}
for name, (goals, games) in record.items():
# 在這裡寫:算 goals / games 保留一位小數放進 result;除以 0 時放 0.0
pass
return result
寫好了先點「執行」試試示例,沒問題再點「提交」。