Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 3 fuera de 29 páginas
Examen

D 522 Exam 2 V3 | D 522 Python for IT Automation | Actual Q&A with Rationale (D522 Exam 2) | Western Governors University

Document preview thumbnail
Vista previa 3 fuera de 29 páginas

D 522 Exam 2 V3 | D 522 Python for IT Automation | Actual Q&A with Rationale (D522 Exam 2) | Western Governors University

Vista previa del contenido

D 522 Exam 2 V3 | D 522 Python for IT
Automation | Actual Q&A with Rationale
(D522 Exam 2) | Western Governors
University
1. When using the subprocess module, which function is recommended for most applications

to execute a child process and wait for it to complete?

A. subprocess.run()


B. subprocess.call()


C. subprocess.popen()


D. subprocess.check_output()


Answer: A


Rationale: The subprocess.run() function was introduced in Python 3.5 and is the current

standard for executing commands. It simplifies the process by waiting for the command to

finish and returning a CompletedProcess instance. This approach is preferred over older

functions like call() because it provides a more robust interface for handling stdout and

stderr.


2. Which regular expression pattern would best identify a standard IPv4 address such as

192.168.1.1?

A. r’...’

,B. r’[a-z]{1,3}.[a-z]{1,3}’


C. r’+.+’


D. r’+’


Answer: A


Rationale: The pattern matches between one and three digits, which corresponds to the

octets in an IPv4 address. The backslash before the dot ensures the literal period is

matched rather than any character. This pattern is fundamental for network automation

scripts that parse log files or configuration outputs.


3. What is the primary benefit of using a context manager (with statement) when opening

files in Python?

A. It automatically closes the file after the block is finished.


B. It encrypts the data written to the file.


C. It increases the speed of file write operations.


D. It allows multiple processes to write to the same file simultaneously.


Answer: A


Rationale: A context manager ensures that file descriptors are released back to the

operating system even if an error occurs within the block. This prevents resource leaks

which can lead to system instability in large automation pipelines. It is a standard Pythonic

best practice that improves code readability and reliability.

, 4. Which method in the ‘os’ module should be used to create a directory if you also need to

create any missing parent directories?

A. os.mkdir()


B. os.path.create()


C. os.system(‘mkdir’)


D. os.makedirs()


Answer: D


Rationale: The os.makedirs() function is recursive, meaning it will create all intermediate-

level directories needed to contain the leaf directory. In contrast, os.mkdir() will raise a

FileNotFoundError if the parent path does not exist. This makes makedirs() highly effective

for setting up log structures or repository paths in automation scripts.


5. In the ‘unittest’ framework, which method is used to verify that two values are identical

during a test case?

A. self.assertTrue()


B. self.assertIdentical()


C. self.checkEqual()


D. self.assertEqual()


Answer: D

Información del documento

Subido en
16 de julio de 2026
Número de páginas
29
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$16.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
ScholarsAscend
3.7
(77)
Vendido
453
Seguidores
39
Artículos
29361
Última venta
12 horas hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes