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 28 páginas
Examen

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

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

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

Vista previa del contenido

D 522 Final Exam V1 | D 522 Python for IT
Automation | Actual Q&A with Rationale
(D522 Final Exam) | Western Governors
University
1. When using the regular expression module in Python, which function should be used to

find every instance of a pattern within a target string?

A. re.findall()


B. re.match()


C. re.search()


D. re.finditer()


Answer: A


Rationale: The re.findall() function is designed to scan the entire string and return all non-

overlapping matches as a list of strings. This is particularly useful in IT automation for

extracting all IP addresses or error codes from a large log file. Unlike re.search(), which

only returns the first match, findall ensures comprehensive data extraction.


2. Which keyword is used to ensure that a file is properly closed after its operations are

complete, even if an exception occurs?

A. with


B. open

,C. close


D. finally


Answer: A


Rationale: The ‘with’ statement in Python creates a context manager that automatically

handles resource cleanup. In the context of IT automation, using ‘with open()’ prevents file

corruption and memory leaks by ensuring the file closes after the block finishes. This is

considered a best practice over manually calling the .close() method.


3. What is the primary purpose of the ‘unittest’ module in a Python automation workflow?

A. To automate the deployment of scripts to production.


B. To verify that individual components of the script work as intended.


C. To create graphical user interfaces for system administrators.


D. To manage external library dependencies via pip.


Answer: B


Rationale: The unittest module provides a framework for creating automated tests to

validate that code behaves correctly. IT automation requires high reliability, so testing

individual functions helps prevent regressions when scripts are updated. It allows

developers to assert that outputs match expected values across various system

environments.

, 4. In the ‘subprocess’ module, which argument should be set to True to capture the output of

a system command for further processing?

A. check


B. shell


C. capture_output


D. text


Answer: C


Rationale: The capture_output=True argument allows the subprocess.run() function to

store the stdout and stderr of the command. This is essential for scripts that need to parse

the results of a shell command to make logic-based decisions. Without this, the output is

simply printed to the console and cannot be assigned to a Python variable.


5. Which logging level should be used for events that indicate an unexpected problem,

though the script is still able to continue running?

A. DEBUG


B. INFO


C. WARNING


D. CRITICAL


Answer: C

Información del documento

Subido en
16 de julio de 2026
Número de páginas
28
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$17.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
13 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