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

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

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

Vista previa del contenido

D 522 Exam 3 V2 | D 522 Python for IT
Automation | Actual Q&A with Rationale
(D522 Exam 3) | Western Governors
University
1. When using the ‘re’ module in Python, which function should an IT professional use to find

all occurrences of a pattern within a string?

A. re.search()


B. re.findall()


C. re.match()


D. re.split()


Answer: B


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

overlapping matches of a pattern as a list of strings. In contrast, re.search() only identifies

the first occurrence of the pattern. Using findall ensures that every instance of the data,

such as IP addresses in a log file, is captured for processing.


2. An automation script needs to check if a specific command-line argument was provided.

Which index of ‘sys.argv’ contains the name of the script itself?

A. sys.argv.name


B. sys.argv[1]

,C. sys.argv[-1]


D. sys.argv[0]


Answer: D


Rationale: The sys.argv list is the standard way to access command-line arguments in

Python scripts. The element at index 0 is always the name of the script being executed by

the interpreter. To access actual user-provided arguments, the script must look at index 1

and beyond.


3. Which subprocess method is recommended for executing a command and waiting for it to

complete in Python 3.5+?

A. subprocess.call()


B. subprocess.exec()


C. subprocess.popen()


D. subprocess.run()


Answer: D


Rationale: The subprocess.run() function was introduced to simplify the process of

starting a process and waiting for it to finish. It returns a CompletedProcess instance which

includes information about the exit status and output. While subprocess.call exists for

backward compatibility, run() is the current standard for basic automation tasks.

, 4. What is the purpose of the ‘capture_output=True’ argument in the subprocess.run()

function?

A. It displays the output directly to the user’s terminal.


B. It saves the output to a text file on the local disk.


C. It prevents the command from generating any output at all.


D. It allows the script to store stdout and stderr in the returned object.


Answer: D


Rationale: By setting capture_output to True, the script instructs the subprocess to

redirect standard output and standard error to pipes. These streams can then be accessed

via the stdout and stderr attributes of the returned CompletedProcess object. This is

essential for scripts that need to parse the results of a system command to make decisions.


5. Which regular expression metacharacter is used to match the start of a string?

A. $


B. *


C. ^


D. +


Answer: C


Rationale: The caret symbol (^) is an anchor in regular expressions that specifies the

match must occur at the beginning of the string. This is useful for identifying log entries

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