Which Python Data Structure Stores Firewall Rule Configurations?
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? - 
Community Votes
62% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The exam tests practical Python data structure selection: dictionaries represent a single rule's fields as key-value pairs, and the trap is confusing storage of multiple rules (a list) with the structure of one rule's configuration (a dictionary).
When storing known-good firewall rule configurations in a Python script, dictionaries are the best data structure because they map rule attributes such as protocol, source, and action to their values. The CompTIA community largely supports dictionaries (C) over lists, citing the natural key-value pairing of configuration settings.
Choosing A (lists) is the most common wrong answer. Test-takers think of firewall rules as a sequence of entries, but a single rule's configuration fields—like name, protocol, source, destination, port, and action—are best modeled as related key-value pairs, not positional list elements.
Community Discussion (4 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Dictionaries store key-value pairs, which exactly matches the idea of a known-good configuration: each configuration parameter has a name and a value. For a firewall rule, parameters such as 'source_ip', 'dest_port', and 'action' can be referenced directly by key, making the dictionary the most natural and readable structure. Community comment 1 correctly states that dictionaries allow for easy association of configuration parameters with their respective values. In penetration-testing automation, using a dictionary (or a list of dictionaries for multiple rules) is the idiomatic Python approach.
Why the Other Options Are Wrong
Lists are ordered collections, but they do not describe attributes by name; you would have to use positional indexing, which is error-prone for configuration data. Tuples are immutable and better suited for fixed records that never change, but firewall rule configurations often need to be referenced or updated by field name, making dictionaries more flexible. Trees are useful for hierarchical relationships, such as rule ordering by chain or zone, but they are overkill for simple rule configuration storage. Community comment 3 argues that a list is needed to group each key/value pair, but that actually points to the common hybrid pattern—a list of dictionaries—not the primary data structure for a single rule's attributes.
Community Comment Notes
Comment 1 (4 likes) strongly supports C by emphasizing the key-value nature of configuration parameters. Comment 2 (2 likes) illustrates the common confusion: it recognizes that a dictionary is key-value but then suggests a list 'like an array,' missing the point that lists store values positionally, not by named key. Comment 3 (1 like) makes a nuanced argument for lists, but it conflates multiple entries with the structure of a single rule; the best practice is to use a dictionary for each rule's attribute set, optionally placed inside a list for multiple rules. Overall, the vote distribution C:63 vs A:38 confirms that most community members recognize the dictionary as the correct fit.
Official Reference
Exam Strategy
For Python data-structure questions, first ask what each entry represents: if you need to store named attributes and retrieve them by field name, choose a dictionary. Remember that when storing many rules, a list of dictionaries is common, but a single rule's known-good configuration is almost always a dictionary.