Data Structures Flashcards
7 cards from real PCEP practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Data Structures flashcards as text
What does `'key' in {'key': 1, 'val': 2}` evaluate to?
Answer: True
The `in` operator checks for key membership in a dictionary.
Which list method inserts an element at a specific index?
Answer: insert()
`insert(index, value)` places a new element before the given index.
What is the value of `d` after `d = {}; d['x'] = 10; d['x'] += 5`?
Answer: {'x': 15}
The key `'x'` is first set to 10, then incremented by 5 to become 15.
What does `sorted({3, 1, 2})` return?
Answer: [1, 2, 3]
`sorted()` always returns a new list, regardless of the input type.
What is the output of `[0] * 4`?
Answer: [0, 0, 0, 0]
Multiplying a list by an integer repeats its elements that many times.
Which dictionary method returns all key-value pairs as view objects?
Answer: items()
`dict.items()` returns a view of `(key, value)` tuple pairs.
What is the result of `{1, 2, 3} & {2, 3, 4}`?
Answer: {2, 3}
The `&` operator returns the intersection — elements common to both sets.