Computer Science I / Basic Data Collections
Practice question · Select all that apply

Select every statement that is true of lists and dictionaries as the lesson describes them.

Hints
  1. Two options describe a dictionary as if it were a list, or miscount a list's indices.
  2. A dictionary uses keys, not positions; a length-4 list stops at index 3.
Show the answer
  • A. Sets do not allow duplicate elements.
  • B. Indexing starts at zero, so the final position of a four-element list is 3.
  • E. Membership testing is faster in a set than in a list.
Why

Lists are ordered and 0-indexed, so the last of n elements is at n minus 1; dictionaries are keyed by meaningful keys, not positions. Option 2 confuses a dictionary with a list, and option 4 makes the off-by-one error at the boundary.

Read the lesson: Basic Data Collections →

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