Courseiva
hardMultiple Select

350-401 Practice Question: Which three statements about using Python for…

Which three statements about using Python for device inventory and data serialization in network automation are true? (Choose three.)

⚠ Common exam trap

The trap here is assuming that JSON is always more human-readable than YAML, or that YAML cannot contain comments, due to unfamiliarity with YAML's features; candidates may incorrectly eliminate the correct options based on these misconceptions.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

A Python script can read a YAML file containing device hostnames and IP addresses, then use that data to connect to each device and gather inventory information.

Option A is correct because Python can load a YAML inventory file with libraries such as PyYAML (yaml.safe_load), iterate over the parsed hostnames and IP addresses, and use those values to drive connections to each device for inventory collection. Option B is correct because Python's built-in json module provides json.dumps() to serialize a dictionary of inventory data into a JSON string suitable for storage or transmission, and json.loads() to deserialize it. Option C is correct because the standard csv module (e.g., csv.DictReader) can parse CSV inventory files containing fields like hostname, IP, and credentials and feed them into an automation script. Option D is incorrect because YAML explicitly supports comments using the # character, so inventory files can include explanatory text. Option E is incorrect because JSON is not always more human-readable than YAML; YAML's indentation-based, comment-friendly syntax is often considered more readable for complex nested structures.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    A Python script can read a YAML file containing device hostnames and IP addresses, then use that data to connect to each device and gather inventory information.

    Why this is correct

    YAML parsing via PyYAML yields hostnames and IPs as native Python structures, which the script iterates over to open per-device sessions and collect inventory. This satisfies the stem's requirement that serialised data drives automated, multi-device gathering rather than manual entry.

  • ✓

    The json module in Python can be used to serialize a dictionary containing device inventory data into a JSON string for storage or transmission.

    Why this is correct

    The json module's `dumps()` function converts Python dictionaries into JSON-formatted strings, satisfying the serialisation requirement for transmitting device inventory data. JSON's lightweight, language-independent structure suits network automation workflows where inventory must be stored or exchanged between systems. This directly addresses the stem's data serialization criterion.

  • ✓

    CSV files can be parsed using Python's csv module to import device inventory data, such as hostname, IP, and credentials, into a script.

    Why this is correct

    Python's built-in csv module reads comma-separated inventory files row by row, mapping each field to hostname, IP or credential variables without external dependencies. This satisfies the stem's device inventory requirement, letting scripts ingest structured tabular data directly rather than parsing raw text manually.

  • ✗

    YAML files in Python cannot contain comments, so all inventory data must be described without explanatory text.

    Why it's wrong here

    Incorrect because YAML supports comments using the '#' character, and Python's PyYAML library can parse files that include comments (though comments are not preserved when dumping).

  • ✗

    JSON is always more human-readable than YAML for complex inventory structures.

    Why it's wrong here

    JSON's brace-and-bracket syntax with quoted keys becomes harder to scan as nesting deepens, whereas YAML's indentation-based block style handles complex hierarchies without delimiters. The claim is tempting because JSON is genuinely readable for flat, shallow structures, and it remains the correct choice when strict machine parsing or broad API compatibility matters more than human editing.

Go deeper

Related to this question

About these practice questions

Courseiva writes every 350-401 question from scratch — 1,923 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Cisco exam blueprint

This 350-401 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 350-401 exam.