hardMultiple Select
350-401 Practice Question: Which three statements about Python functions and…
Which three statements about Python functions and modules for network automation are true? (Choose three.)
⚠ Common exam trap
Test-takers frequently confuse standard-library module names — candidates often assume 'os' or 'csv' handle JSON because they sound generic, when only 'json' does.
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
✓
Using functions helps avoid code duplication and improves script maintainability.
Option A is correct because defining reusable functions encapsulates logic so the same code can be called from multiple places, eliminating copy-paste duplication and making scripts easier to read, test, and maintain. Option C is correct because the json module provides json.loads() to deserialize a JSON-formatted string into Python dictionaries/lists, which is exactly how automation scripts convert device API responses into usable Python objects. Option E is correct because the re module supplies regular-expression matching (re.search, re.findall, re.match) that is ideal for pulling structured values such as interface names, IP addresses, or uptime out of unstructured 'show' command output. Option B is not correct because the os module handles operating-system interactions like paths and environment variables, not JSON parsing. Option D is not correct because the csv module reads and writes comma-separated value files, not JSON data returned by network devices.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Using functions helps avoid code duplication and improves script maintainability.
Why this is correct
Functions encapsulate reusable logic, so repeated configuration or parsing tasks are defined once and called many times, directly satisfying the maintainability constraint in the stem. This reduces duplication across scripts, lowering the risk of inconsistent edits when changes are required.
- ✗
The os module is used to parse JSON data from network device responses.
Why it's wrong here
The os module provides operating-system interfaces such as file paths and environment variables; JSON parsing belongs to the json module. It is tempting because scripts often combine both, but os would be correct for reading credentials from environment variables.
- ✓
The json module is used to convert JSON strings to Python dictionaries.
Why this is correct
The json module's `json.loads()` method deserialises JSON-formatted strings into Python dictionaries, enabling scripts to parse API responses from controllers and devices. This satisfies the scenario's requirement for converting JSON strings into native Python data structures for further manipulation.
- ✗
The csv module is used to parse JSON data from network devices.
Why it's wrong here
The csv module reads and writes comma-separated value files; JSON parsing is handled by the json module. It is tempting because both process structured text, but csv would be correct when ingesting tabular exports such as device inventory spreadsheets.
- ✓
The re module is useful for extracting specific patterns from device show command output.
Why this is correct
The re module provides regular expression matching, letting scripts parse CLI output such as interface tables or routing entries and extract only the fields required. This satisfies the automation need to pull structured values from unstructured show command text rather than dumping raw output.
Go deeper
Related to this question
Learn chapter
Network Automation and Programmability
Key term
REST API for Network Devices
A REST API for network devices is a set of rules that allows software applications to communicate with routers, switches, and firewalls using standard web methods like GET, POST, PUT, and DELETE over HTTP or HTTPS.
Key term
Cisco DNA Center Automation
Cisco DNA Center Automation is a centralized software platform that simplifies network management by automatically configuring, monitoring, and troubleshooting Cisco devices using policy-driven intent and software tools.
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 →
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.