CompTIA PenTest+ (PT0-002) — Question 206
Within a Python script, a line that states print (var) outputs the following:
[{'1' : 'CentOS', '2' : 'Ubuntu'}, {'1' : 'Windows 10', '2' : 'Windows Server 2016'}]
Which of the following objects or data structures is var?
Answer options
- A. An array
- B. A class
- C. A dictionary
- D. A list
Correct answer: D
Explanation
The correct answer is D, a list, because the output shows a collection of dictionary objects enclosed in square brackets, which indicates a list structure. Options A, B, and C are incorrect as they do not represent the overall structure being displayed; an array is not a native Python type, a class is a blueprint for creating objects, and a dictionary is a key-value pair structure, but the entire structure here is a list of dictionaries.