BANK & PERFORMANCE ASSESSMENT GUIDE
QUESTION AND ANSWERS WITH RATIONALES
Master your network automation curriculum with this
comprehensive, high-yield exam bank featuring realistic
multiple-choice questions complete with italicized answers
and bold italic rationales. The study guide directly addresses
core programming pillars, including idempotent directory
configuration management, automated DNS zone file
remediation, structured JSON logging schemas, and robust
pytest verification strategies. Perfect for securing a first-
attempt pass on your technical assessments, this study
guide serves as a top-tier reference for both coursework
completion and passive income monetization.
Question 1
When implementing an automated configuration remediation
script, which Python module from the standard library is preferred
for managing filesystem paths in an object-oriented, cross-
platform manner to ensure idempotent directory creation?
A) os.path
B) pathlib
C) sys
D) shutil
,Answer: B) pathlib
Rationale: The pathlib module, introduced in Python 3.4,
provides an object-oriented approach to parsing filesystem
interactions. Using Path.mkdir(parents=True, exist_ok=True)
ensures idempotency, meaning the script can execute
Question 11
When parsing a CSV file containing network node inventories
in an automated script, which approach handles the file
object most securely to prevent memory leaks and dangling
file descriptors if an unhandled runtime error occurs?
A) Opening the file using f = open('nodes.csv') and relying on
the garbage collector
B) Using the with open('nodes.csv', mode='r') as f: context
manager expression
C) Reading the raw binary buffer directly from the root OS
disk sector
D) Running an external shell script via os.system('cat
nodes.csv')
Answer: B) Using the with open('nodes.csv', mode='r') as f:
context manager expression
Rationale: The with statement instantiates a context manager
that guarantees the file descriptor is implicitly closed when
execution exits the block. This cleanup occurs even if an
unhandled exception or crash happens inside the loop,
preventing file system locks and memory exhaustion.
Question 12
,An IT engineer needs to update an infrastructure metric
across a massive inventory of switches. Which loop control
structure optimization should be used in Python to iterate
over paired device identifiers and IP strings stored as key-
value pairs?
A) for device in dictionary.keys():
B) for device, ip in dictionary.items():
C) while len(dictionary) > 0:
D) for i in range(len(dictionary)):
Answer: B) for device, ip in dictionary.items():
Rationale: The .items() method yields a stream of key-value
tuples from a dictionary object. This allows direct, unpacked
assignment of both variables in a single loop step,
eliminating the need to look up keys manually inside the
block, which optimizes execution runtime.
Question 13
During a script execution tracking routine, an engineer wants
to dynamically construct an error message string that
embeds the target hostname and a numerical error code.
According to PEP 8 standards, what is the most legible and
efficient modern way to format this string?
A) "Error on host " + host + " with code: " + str(code)
B) "Error on host %s with code: %d" % (host, code)
C) f"Error on host {host} with code: {code}"
D) "Error on host {} with code: {}".format(host, code)
Answer: C) f"Error on host {host} with code: {code}"
Rationale: Formatted string literals (f-strings) evaluate
, expressions inside curly braces at runtime. They execute
faster than older concatenation methods or .format() calls
because they parse directly into optimized bytecode
instructions, making them the preferred choice for clean and
readable code.
Question 14
A validation script uses the requests library to test the status
of a secondary DNS dashboard API. Which property of the
response object should be checked to quickly evaluate if the
HTTP request completed successfully without parsing the
text body?
A) response.headers
B) response.status_code
C) response.cookies
D) response.url
Answer: B) response.status_code
Rationale: The status_code attribute contains the standard
three-digit HTTP status response integer. An automation
script can instantly confirm success by validating that this
code falls within the 200–299 range, avoiding the processing
overhead of reading long HTML or JSON payloads.
Question 15
If a Python remediation script needs to pass sensitive
credentials—such as a Helpdesk API token or service
account password—to a workflow, what is the safest method