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 Exam 4 V1 | D 522 Python for IT Automation | Actual Q&A with Rationale (D522 Exam 4) | Western Governors University

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

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

Vista previa del contenido

D 522 Exam 4 V1 | D 522 Python for IT
Automation | Actual Q&A with Rationale
(D522 Exam 4) | Western Governors
University
1. When using the os module, which function is best suited to verify if a file exists before

attempting to read its contents?

A. os.path.exists()


B. os.path.isfile()


C. os.access()


D. os.check_path()


Answer: A


Rationale: The os.path.exists() function returns True if a file or directory at the specified

path exists. This is a fundamental safety check in automation scripts to prevent

FileNotFoundError exceptions. Using this ensures that the script logic remains robust

when dealing with dynamic file system environments.


2. In the re module, what is the primary difference between re.search() and re.match()?

A. re.search() scans the whole string for a match anywhere, while re.match() checks only at

the beginning.


B. re.match() scans the entire string for any occurrence.

,C. re.search() looks for patterns only at the beginning of a string.


D. There is no functional difference between the two methods.


Answer: A


Rationale: The re.search() function is more flexible for log analysis because it finds

patterns regardless of their position. In contrast, re.match() will fail if the pattern is not

found at the very start of the string. Understanding this distinction is critical for IT

professionals who need to parse complex data streams.


3. Which subprocess.run() argument is used to capture the standard output and standard

error of a command?

A. capture_output=True


B. shell=True


C. check=True


D. stdout=PIPE


Answer: A


Rationale: The capture_output=True argument allows a script to store the result of an

external command in the CompletedProcess object. This is essential for processing the

results of shell commands within a Python workflow. Without this, the output is printed

directly to the terminal rather than being saved for variable manipulation.

, 4. What is the significance of the sys.argv list in Python automation scripts?

A. It stores the local environment variables of the operating system.


B. It tracks the memory usage of the running process.


C. It defines the system path for importing external libraries.


D. It is used to store the command-line arguments passed to the script.


Answer: D


Rationale: The sys.argv list is the standard way to accept user inputs or flags when

running a script from the command line. The first element, sys.argv[0], always refers to the

script name itself. This allows administrators to create versatile tools that behave

differently based on the parameters provided at runtime.


5. Which unittest method is used to verify that two values are identical during a test case?

A. assertValue()


B. assertEqual()


C. assertSame()


D. assertTrue()


Answer: B


Rationale: The assertEqual() method is the core tool for checking that the output of a

function matches the expected result. If the values do not match, the test fails and provides

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
$15.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