โ† All POC Flashcard Decks

Data Structures & File Handling Flashcards

7 cards from real POC 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 & File Handling flashcards as text
  1. What does `collections.defaultdict(list)` do when a missing key is accessed?

    Answer: Automatically creates an empty list for that key

    `defaultdict` calls the factory function (`list`) to generate a default value for any missing key, avoiding KeyError.

  2. Which method flushes the internal write buffer to the OS without closing the file?

    Answer: f.flush()

    `f.flush()` forces Python's internal I/O buffer to be written to the operating system immediately, without closing the file.

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

    Answer: {2, 3}

    The `&` operator computes the intersection of two sets, returning only elements present in both.

  4. When reading a CSV file with Python's `csv.reader`, what type does each row come back as?

    Answer: A list of strings

    `csv.reader` yields each row as a list of strings, where each element corresponds to a field in that row.

  5. Which statement correctly inserts value `99` at index 2 of list `L`?

    Answer: L.insert(2, 99)

    `list.insert(i, x)` inserts element `x` before the item at index `i`, shifting subsequent elements right.

  6. What does `dict.items()` return in Python 3?

    Answer: A view object of (key, value) pairs

    In Python 3, `dict.items()` returns a dynamic view object of `(key, value)` tuples that reflects dictionary changes in real time.

  7. What happens when you open a file with mode `'a'` and write to it?

    Answer: Data is appended to the end of the file

    Append mode (`'a'`) positions the write pointer at the end of the file, so new data is added after existing content.

Data Structures & File Handling Flashcards โ€” POC Study Cards with Answers