CompTIA PenTest+ (PT0-002) — Question 366

Which of the following Python data structures is the best way to store a group of key-value pair objects?

Answer options

Correct answer: D

Explanation

The correct answer is D, Dictionaries, as they are specifically designed to store data in key-value pairs, allowing for efficient retrieval. Arrays, Lists, and Trees do not inherently support this structure; arrays and lists store items in a linear fashion, while trees represent hierarchical data, making them less suitable for key-value storage.