DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
9. D. The os module allows you to interact with the
file system and directory structure of the
operating system.
10. A. Cisco built pyATS and released it to open
source for testing Cisco infrastructure software.

CHAPTER 5


1. C. The end-of-line is the last character of a line of
text before the text wraps to the next line. This is
identified as \n or as EoF (end of file).
2. A. In order to open a file for writing, you need to
use the open() function and assign it to a file
handler variable—in this case, data. In addition,
you need to pass the name of the file and tell
Python that you want to allow write access to it
(using “w”).
3. C. Using the with open combo to the text.csv
file, you map it to the filehandle object. Map
csv_writer, which is just another Python object,
to the csv.writer(filehandle) function. Next,
you write your data to the CSV file by calling the
.writerow method.
4. B. The xmltodict module reads XML data.
5. A, C. To load a native JSON file into a Python
string object, you use loads(), which stands for
load string, and to convert a Python string into
native JSON, you use dump().
6. B. YAML stands for YAML Ain’t Markup
Language.
7. A. Error handling in Python can be conducted by
using a try-except-else-finally block.
8. C. finally is executed every time the code runs
through the try block. It is often used to clean up
variables or alert the user to a success or failure
event.
Free download pdf