nerdexam
Cisco

350-401 · Question #429

Refer to the exhibit. What is achieved when this Python script is executed?

The correct answer is D. Each device that is looped through in the devices.txt file is put into its own dictionary that is. The Python script processes each device entry from the devices.txt file and organizes each device's attributes into its own dictionary.

Submitted by cyberguy42· Mar 6, 2026Automation

Question

Refer to the exhibit. What is achieved when this Python script is executed?

Exhibits

350-401 question #429 exhibit 1
350-401 question #429 exhibit 2

Options

  • AAll devices that are looped through in the devices.txt file are put into a list that is appended to the
  • BAll devices that are looped through in the devices.txt file are put into a single dictionary that is
  • CEach device that is looped through in the devices.txt file is put into its own list that is appended to
  • DEach device that is looped through in the devices.txt file is put into its own dictionary that is

How the community answered

(22 responses)
  • A
    5% (1)
  • B
    14% (3)
  • C
    5% (1)
  • D
    77% (17)

Why each option

The Python script processes each device entry from the `devices.txt` file and organizes each device's attributes into its own dictionary.

AAll devices that are looped through in the devices.txt file are put into a list that is appended to the

This option suggests that all devices are consolidated into a single list without specifying the structured nature of each device's data, which is less flexible and descriptive than using dictionaries for device attributes.

BAll devices that are looped through in the devices.txt file are put into a single dictionary that is

Putting all devices into a single dictionary typically implies that each device is identified by a unique key within that dictionary (e.g., device name as key), which is different from 'each device ... put into its own dictionary'.

CEach device that is looped through in the devices.txt file is put into its own list that is appended to

Storing each device's attributes in its own list (e.g., `['hostname', 'ip', 'os']`) is less descriptive and harder to access by specific attribute names compared to using a dictionary with meaningful keys (e.g., `{'hostname': 'R1', 'ip': '1.1.1.1'}`).

DEach device that is looped through in the devices.txt file is put into its own dictionary that isCorrect

When iterating through a file where each line represents a device, it is a common and efficient Python programming practice to parse each line's data (e.g., hostname, IP address, OS type) and store these attributes as key-value pairs in a distinct dictionary for each individual device, which are then typically collected into a list of dictionaries.

Concept tested: Python list of dictionaries data structure for parsing files

Source: https://docs.python.org/3/tutorial/datastructures.html

Topics

#Python scripting#Python data structures#File I/O

Community Discussion

No community discussion yet for this question.

Full 350-401 Practice