Mastery check
Learn~2 min

Trace: keep the table

Predict the output. Before you answer, write down what menu holds after every line.

menu = {}
menu['tea'] = 3
menu['cake'] = 5
menu['tea'] = 4
print(menu)
print(len(menu))
print('cake' in menu)
print(5 in menu)
print(menu['tea'] + menu['cake'])

Reminder

Keep a running table: {} → {tea: 3} → {tea: 3, cake: 5} → {tea: 4, cake: 5}. Then answer each print from the table.

No labels here: choosing the approach is part of what this tests. The skills it trains show once you pass.

Predict the output