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

D 522 Exam 2 V2 | 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 V2 | D 522 Python for IT
Automation | Actual Q&A with Rationale
(D522 Exam 2) | Western Governors
University
1. When using the subprocess module, which parameter of the run() function is required to

capture the standard output of a command so it can be accessed in the script?

A. shell=True


B. check=True


C. capture_output=True


D. timeout=10


Answer: C


Rationale: The capture_output parameter is essential when the script needs to process the

result of a system command. When set to True, both stdout and stderr are captured and

stored in the returned CompletedProcess object. This allows the developer to read the

command’s response rather than just seeing it printed to the terminal.


2. In the context of Regular Expressions, what is the purpose of the ‘?’ quantifier?

A. Matches zero or more occurrences


B. Matches one or more occurrences


C. Matches exactly one occurrence

,D. Matches zero or one occurrence


Answer: D


Rationale: The question mark in a regex pattern signifies that the preceding character or

group is optional. This means it matches either zero or one instance of that specific

element. It is frequently used for handling optional characters like the ‘s’ in ‘https’ or

optional punctuation.


3. Which function from the ‘os’ module should be used to combine directory paths in a way

that is portable across different operating systems?

A. os.path.combine()


B. os.path.merge()


C. os.path.join()


D. os.path.add()


Answer: C


Rationale: The os.path.join function intelligently concatenates path segments using the

correct separator for the host operating system. This prevents errors that occur when

hardcoding forward or backward slashes into script strings. Utilizing this function ensures

that automation scripts remain functional on both Linux and Windows environments.


4. What is the primary difference between the ‘r+’ and ‘w+’ file opening modes in Python?

A. ‘r+’ creates a new file if it does not exist, while ‘w+’ does not.

, B. ‘w+’ truncates the file to zero length if it exists, while ‘r+’ does not.


C. ‘r+’ is for binary files and ‘w+’ is for text files.


D. There is no difference between the two modes.


Answer: B


Rationale: The ‘r+’ mode opens a file for both reading and writing without erasing the

existing content. In contrast, ‘w+’ also allows reading and writing but will overwrite any

existing file content immediately upon opening. Understanding this distinction is critical

for data integrity when automating file updates.


5. When writing unit tests using the ‘unittest’ framework, which method is used to verify that

two values are the same?

A. self.checkEqual()


B. self.assertMatch()


C. self.verify()


D. self.assertEqual()


Answer: D


Rationale: The assertEqual method is the standard way to check for equality within a test

case class. If the two provided arguments are not equal, the test will fail and report the

discrepancy. This is a fundamental tool for verifying that automation logic produces the

expected output values.

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