PT0-002 · Question #517
Given the following table: Which of the following data structures would most likely be used to store Known-good configurations of firewall rules in a Python script?
The correct answer is C. Dictionaries. A dictionary is the most suitable Python data structure for storing firewall rules because it allows for key-value pairs, associating rule names or identifiers with their detailed configurations.
Question
Given the following table:
Which of the following data structures would most likely be used to store Known-good configurations of firewall rules in a Python script?
Exhibit
Options
- ALists
- BTrees
- CDictionaries
- DTuples
How the community answered
(29 responses)- A7% (2)
- B3% (1)
- C90% (26)
Why each option
A dictionary is the most suitable Python data structure for storing firewall rules because it allows for key-value pairs, associating rule names or identifiers with their detailed configurations.
Lists are ordered collections, but accessing specific rules by an identifier would require iteration, and they don't inherently store data as key-value pairs for configuration settings.
Trees are not a built-in Python data type and would typically be implemented using nested dictionaries or custom classes, making "dictionaries" the more direct and appropriate answer for a basic Python script.
Dictionaries are ideal for storing structured data like firewall rules where each rule might have multiple attributes (e.g., protocol, port, source, destination). They allow for accessing specific rules efficiently by a unique key (e.g., rule ID or name) and can hold complex nested structures representing the rule's parameters.
Tuples are immutable ordered collections, suitable for fixed sequences of items, but not for dynamic configurations that require easy lookup and modification of specific rules by a key.
Concept tested: Python data structures for configuration storage
Source: https://docs.python.org/3/tutorial/datastructures.html#dictionaries
Topics
Community Discussion
No community discussion yet for this question.
