Dictionaries
Python Dictionary Interview Questions
Dictionaries are how you count and group by key in Python. Almost every question phrased as "how many X per Y" turns out to be a dictionary question.
What dictionary questions ask you to do
Across the questions here, these are the shapes that come up:
- Count how often each value appears, and take the top few
- Group rows into lists by a key
- Turn a mapping around so the values become the keys
- Merge two mappings with a rule for clashes
- Remember a result so it is not worked out twice
Common mistakes with dictionaries
Asking for a key that is not there raises an error, which is why first attempts end up full of checks for whether a key exists yet. Asking with a default value, or using defaultdict or Counter, removes every one of those checks.
Questions to practice
Questions last reviewed 19 October 2026.
Roles this comes up in
Companies these come from
Other topics
- Filtering7
- Logical operators4
- Calculations11
- Conditional logic12
- NULL handling9
- Dates16
- Joins15
- Aggregations14
- Subqueries5
- Window functions32
- Reshaping15
- Arrays6
- Strings11
- Hashing8
- Two pointers4
- Sliding window1
- Binary search4
- Sorting1
- Math3
- Lists5
- Tuples3
- Ranking16
- Running totals10
- Deduplication2
- Chunking1
- Similarity1
- Token budget2
- Parsing4
- Backoff3
- Agent loop1
- Cost1