350-401 · topic practice

Python for Network Automation practice questions

Practise ENCOR 350-401 Python for Network Automation practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Reviewed byJohnson Ajibi· MSc IT Security
20 questionsDomain: Python for Network Automation

What the exam tests

What to know about Python for Network Automation

Python for Network Automation questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Python for Network Automation exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Practice set

Python for Network Automation questions

20 questions · select your answer, then reveal the explanation

Question 1mediummultiple choice
Study the full Python automation breakdown →

A network engineer is writing a Python script to automate the backup of running configurations from a list of 50 Cisco IOS-XE devices. The script uses the netmiko library and a for loop to connect to each device, execute 'show run', and write the output to a file. After running the script, the engineer notices that the script fails on the 15th device with a timeout error, and the remaining devices are not processed. The engineer wants to ensure that if one device fails, the script continues with the next device. What is the best way to modify the script?

Question 2mediummultiple choice
Study the full Python automation breakdown →

An engineer is using the Cisco DNA Center REST API to retrieve a list of network devices and their health scores. The engineer writes a Python script using the requests library. The script successfully retrieves data for the first 100 devices, but when trying to get the next 100, the API returns an empty list. The engineer checks the API documentation and finds that the endpoint supports pagination with the 'offset' and 'limit' parameters. The current script does not handle pagination. What should the engineer do to retrieve all devices?

Question 3hardmultiple choice
Open the full VLAN trunking answer →

A network engineer is automating the configuration of VLANs on a Cisco Nexus 9000 switch using Python and the NX-API. The engineer sends a Python dictionary with the CLI commands to the API and receives a successful response. However, when checking the switch, the VLANs are not created. The engineer verifies that the credentials and IP address are correct, and the API is enabled. The engineer also notices that the API response contains a 'code' field of '200' and a 'result' field that shows the command output. What is the most likely cause of the issue?

Question 4mediummultiple choice
Study the full Python automation breakdown →

A junior engineer is tasked with writing a Python script that uses the Cisco IOS-XE RESTCONF API to retrieve the hostname of a router. The engineer uses the requests library and sends a GET request to the URL 'https://router/restconf/data/Cisco-IOS-XE-native:native/hostname'. The request returns a 404 Not Found error. The engineer has verified that the RESTCONF service is enabled and the credentials are correct. What is the most likely reason for the 404 error?

Question 5mediummultiple choice
Open the full VLAN trunking answer →

A network engineer is using the Cisco Meraki Dashboard API to automate the creation of VLANs across multiple networks. The engineer writes a Python script that uses the 'createNetworkVlan' endpoint. The script runs successfully for the first few networks, but then starts returning HTTP 429 errors. The engineer checks the API documentation and finds that the Meraki API has rate limits. The script currently sends requests as fast as possible. What should the engineer implement to avoid hitting the rate limit?

An engineer is writing a Python script to parse the output of 'show ip interface brief' from multiple Cisco routers. The engineer uses the netmiko library to collect the output and then uses regular expressions to extract the interface name, IP address, and status. The script works correctly for most routers, but on one router, the output format is slightly different (e.g., extra spaces or different column headers). The engineer wants to make the parsing more robust. What is the best approach?

Question 7easymultiple choice
Open the full VLAN trunking answer →

A network engineer is automating the deployment of a new VLAN configuration across 100 Cisco IOS-XE switches using Ansible. The engineer writes a playbook that uses the 'ios_config' module. The playbook runs, but the engineer notices that the configuration is applied to only 50 switches before the playbook stops with an error. The error message indicates that one switch is unreachable. The engineer wants to ensure that the playbook continues with the remaining switches even if some are unreachable. What Ansible configuration should the engineer use?

Question 8hardmultiple choice
Study the full QoS explanation →

An engineer is using the Cisco pyATS framework to test the configuration of a new QoS policy on a router. The engineer writes a testbed file and a test script that logs into the router, applies the configuration, and then verifies the output of 'show policy-map interface'. The test script fails because the verification step cannot find the expected output. The engineer confirms that the configuration was applied successfully. What is the most likely cause of the failure?

A network engineer is automating the collection of syslog messages from a Cisco ASA firewall using a Python script that connects via SSH and runs 'show log'. The script uses the paramiko library. The script works for a few minutes, but then the SSH connection drops with an error 'Server connection dropped'. The engineer suspects that the ASA is closing the connection due to inactivity. What is the best way to keep the connection alive?

Question 10mediummultiple choice
Study the full Python automation breakdown →

A network engineer writes the following Python script using Netmiko to configure a Cisco IOS-XE device:

```python

from netmiko import ConnectHandler

device = { 'device_type': 'cisco_ios', 'ip': '192.168.1.1', 'username': 'admin', 'password': 'cisco123',

}

connection = ConnectHandler(**device) output = connection.send_command('show ip interface brief')

print(output)

connection.disconnect() ```

What is the primary issue with this script?

Question 11mediummultiple choice
Study the full Python automation breakdown →

A network engineer uses NAPALM to retrieve the ARP table from a Cisco IOS-XE device:

```python

from napalm import get_network_driver

driver = get_network_driver('ios') device = driver('192.168.1.1', 'admin', 'cisco123') device.open() arp_table = device.get_arp_table()

print(arp_table)

device.close() ```

What is the expected data type of arp_table?

Question 12hardmultiple choice
Open the full VLAN trunking answer →

A network engineer writes an Ansible playbook to configure a VLAN on a Cisco Nexus switch:

```yaml --- - name: Configure VLAN hosts: nxos_switches gather_facts: no tasks: - name: Create VLAN 100 cisco.nxos.nxos_vlan: vlan_id: 100 name: test_vlan state: present ```

What is a potential issue with this playbook?

A network engineer uses the Requests library to query a Cisco IOS-XE device via RESTCONF for interface statistics:

```python

import requests
from requests.auth import HTTPBasicAuth

url = 'https://192.168.1.1/restconf/data/Cisco-IOS-XE-interfaces-oper:interfaces/interface=GigabitEthernet1/statistics' headers = {'Accept': 'application/yang-data+json'} auth = HTTPBasicAuth('admin', 'cisco123') response = requests.get(url, headers=headers, auth=auth, verify=False)

print(response.json())

```

What is the most likely issue with this code?

Question 14mediummultiple choice
Study the full Python automation breakdown →

A network engineer uses the Cisco DNA Center REST API to retrieve the list of devices. The API returns the following JSON:

```json

{
  "response": [
    {
      "id": "12345678-1234-1234-1234-123456789abc",
      "managementIpAddress": "192.168.1.1",
      "hostname": "Router1",
      "platformId": "ISR4331",
      "role": "ACCESS",
      "series": "ISR4300 Series"
    }
  ],
  "version": "1.0"
}

```

The engineer writes the following Python code to extract the hostname of the first device:

```python

import requests

url = 'https://dna-center.local/dna/intent/api/v1/network-device' headers = {'X-Auth-Token': 'valid_token', 'Accept': 'application/json'} response = requests.get(url, headers=headers, verify=False) data = response.json()

hostname = data['response'][0]['hostname']
print(hostname)

```

What is a potential issue with this code?

A network engineer configures model-driven telemetry on a Cisco IOS-XE device using gRPC dial-out. The subscription configuration snippet is:

``` telemetry ietf subscription 100 encoding encode-kvgpb filter xpath /interfaces/interface/statistics stream yang-push update-policy periodic 500 receiver ip address 10.1.1.1 50001 protocol grpc-tcp ```

What is the primary issue with this configuration?

Question 16mediummultiple choice
Study the full Python automation breakdown →

A network engineer writes a Python script using Paramiko to execute a command on a Cisco IOS device:

```python

import paramiko

ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('192.168.1.1', username='admin', password='cisco123') stdin, stdout, stderr = ssh.exec_command('show version') output = stdout.read().decode()

print(output)

ssh.close() ```

What is a potential issue with this approach?

Question 17mediummultiple choice
Study the full Python automation breakdown →

A network engineer uses the Requests library to send a RESTCONF PATCH request to modify the hostname of a Cisco IOS-XE device:

```python

import requests
from requests.auth import HTTPBasicAuth

url = 'https://192.168.1.1/restconf/data/Cisco-IOS-XE-native:native/hostname' headers = {'Content-Type': 'application/yang-data+json'} auth = HTTPBasicAuth('admin', 'cisco123') payload = { 'Cisco-IOS-XE-native:hostname': 'NewRouter'

}

response = requests.patch(url, json=payload, headers=headers, auth=auth, verify=False)

print(response.status_code)

```

What is the expected HTTP status code if the request is successful?

Question 18hardmultiple choice
Read the full Ansible explanation →

A network engineer writes an Ansible playbook to gather facts from a Cisco IOS device using the ios_facts module:

```yaml --- - name: Gather IOS Facts hosts: ios_devices gather_facts: no tasks: - name: Collect facts cisco.ios.ios_facts: gather_subset: - hardware register: device_facts

- name: Show serial number debug: msg: "Serial number is {{ device_facts['ansible_facts']['ansible_net_serialnum'] }}" ```

What is a potential issue with this playbook?

Question 19mediummultiple choice
Study the full Python automation breakdown →

Examine the following Python script snippet that uses netmiko to configure a Cisco IOS-XE device:

```python

from netmiko import ConnectHandler

device = { 'device_type': 'cisco_ios', 'ip': '192.168.1.1', 'username': 'admin', 'password': 'cisco',

}

connection = ConnectHandler(**device) output = connection.send_command('show ip interface brief')

print(output)

connection.disconnect() ```

What is the primary purpose of this script?

Question 20mediummultiple choice
Study the full Python automation breakdown →

Consider the following Python script using the requests library to interact with a Cisco IOS-XE device via RESTCONF:

```python

import requests
from requests.auth import HTTPBasicAuth

url = 'https://192.168.1.1/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1/0/1' headers = { 'Accept': 'application/yang-data+json', 'Content-Type': 'application/yang-data+json'

}

auth = HTTPBasicAuth('admin', 'cisco')

response = requests.get(url, headers=headers, auth=auth, verify=False)

print(response.json())

```

What is the script attempting to do?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Python for Network Automation sessions

Start a Python for Network Automation only practice session

Every question in these sessions is drawn from the Python for Network Automation domain — nothing else.

Related practice questions

Related 350-401 topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the 350-401 exam test about Python for Network Automation?
Python for Network Automation questions test whether you can apply the concept in context, not just recognise a definition.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Python for Network Automation questions in a focused session?
Yes — the session launcher on this page draws every question from the Python for Network Automation domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other 350-401 topics?
Use the topic links above to move to related areas, or go back to the 350-401 question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the 350-401 exam covers. They are not copied from any real exam or dump site.