Practice question · Multiple choice
A list stores elements by sequential position, whereas a dictionary associates values with unique keys. What design consequence follows from this difference when choosing how to represent entity data?
Hints
- How do you address an individual value when numeric position carries no meaning?
- Does a key provide identity, or does it enforce sequential ordering?
Show the answer
A. A dictionary requires meaningful identifiers rather than sequence
Why
Positional sequences rely on an item's place in line, whereas map-like structures depend entirely on distinct lookup labels. Dictionaries do not sort their entries numerically or alphabetically, nor do lists restrict repeated elements or permit arbitrary retrieval without an index.
Practise Basic Data Collections
The app has 7 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Basic Data Collections
- Select every statement that is true of lists and dictionaries as the lesson describes them.
- A list preserves order and allows duplicates; a set does neither and can test membership far faster. Why does…
- For a list of length 4 (valid indices 0 through 3), sort each index by whether accessing it is valid.