nerdexam
CompTIA

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.

Tools and Code Analysis

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

PT0-002 question #517 exhibit

Options

  • ALists
  • BTrees
  • CDictionaries
  • DTuples

How the community answered

(29 responses)
  • A
    7% (2)
  • B
    3% (1)
  • C
    90% (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.

ALists

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.

BTrees

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.

CDictionariesCorrect

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.

DTuples

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

#Python#Data Structures#Scripting#Configuration Storage

Community Discussion

No community discussion yet for this question.

Full PT0-002 Practice