Dictionary basics
18-minute lesson · module-dictionaries-01
You are previewing this course as a guest
Read anything and run any exercise you like. It all runs in your own browser, so nothing here is saved: no XP, no progress, and the AI tutor needs an account. Sign in and your work starts counting.
Dictionary basics
18-minute lesson · module-dictionaries-01
- Create a dictionary literal and an empty dictionary.
- Look up, insert, update, and delete entries by key.
- Iterate over keys, values, and items.
- Use `in` to test for key membership without raising KeyError.
Source attribution
Status: adapted
How to Think Like a Computer Scientist: Interactive Edition — source · Dictionaries / Intro to Dictionaries / Dictionary operations
Adaptation notes. Reading rewritten in our voice. Worked example uses an Iowa State CS courses-and-credits theme. Hidden tests check insertion, update, membership, and KeyError handling.
License notes. Original chapter is GNU FDL 1.3 (Brad Miller, David Ranum, and the upstream Elkner/Downey/Meyers text). No verbatim text reproduced.