Certified Professional in Python Programming (PCPP-32-101) — Question 22
Select the correct statements about the csv module. (Choose two.)
Answer options
- A. A DictReader object maps each row to a diet.
- B. The DictReader method always gets the header from the first line in the file.
- C. It is possible to create a DictWriter object without specifying a header.
- D. A reader object maps each row to a list of strings.
Correct answer: B, D
Explanation
Option B is correct because the DictReader method indeed reads the header from the first line of the file. Option D is also correct as a reader object creates a list of strings for each row. Options A and C are incorrect because a DictReader does not map to a diet, and a DictWriter requires specifying a header.