← All PCEP Flashcard Decks

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
  1. What does `'key' in {'key': 1, 'val': 2}` evaluate to?

    Answer: True

    The `in` operator checks for key membership in a dictionary.

  2. Which list method inserts an element at a specific index?

    Answer: insert()

    `insert(index, value)` places a new element before the given index.

  3. 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.

  4. What does `sorted({3, 1, 2})` return?

    Answer: [1, 2, 3]

    `sorted()` always returns a new list, regardless of the input type.

  5. What is the output of `[0] * 4`?

    Answer: [0, 0, 0, 0]

    Multiplying a list by an integer repeats its elements that many times.

  6. Which dictionary method returns all key-value pairs as view objects?

    Answer: items()

    `dict.items()` returns a view of `(key, value)` tuple pairs.

  7. What is the result of `{1, 2, 3} & {2, 3, 4}`?

    Answer: {2, 3}

    The `&` operator returns the intersection — elements common to both sets.