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 V3 | 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 V3 | 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 V3 | D 522 Python for IT
Automation | Actual Q&A with Rationale
(D522 Final Exam) | Western Governors
University
1. Which function from the ‘os’ module is used to check if a specific file or directory path

currently exists on the system?

A. os.path.isfile()


B. os.path.exists()


C. os.access()


D. os.path.isdir()


Answer: B


Rationale: The os.path.exists() function is the primary tool for verifying the presence of a

file or directory at a given path. It returns True if the path is valid and False if the location

does not exist. This is a fundamental check in automation to prevent execution errors when

resources are missing.


2. In the ‘sys’ module, what information is typically stored at index 0 of the ‘sys.argv’ list?

A. The first command-line argument provided by the user


B. The name of the script being executed


C. The total number of arguments passed to the script

,D. The current working directory of the process


Answer: B


Rationale: In Python, sys.argv[0] contains the name of the script that is currently running.

All subsequent elements in the list represent the additional arguments passed via the

terminal. Understanding this indexing is crucial for parsing user input correctly in CLI

automation tools.


3. When using the ‘re’ module, which method should be used to find all occurrences of a

pattern within a string and return them as a list?

A. re.search()


B. re.findall()


C. re.match()


D. re.finditer()


Answer: B


Rationale: The re.findall() method scans the entire string and extracts every substring that

matches the provided regular expression. Unlike re.search(), which only finds the first

match, findall() compiles every instance into a list. This is particularly useful for log parsing

when multiple entries need to be analyzed.


4. Which parameter in ‘subprocess.run()’ must be set to True to capture the output of a

command so it can be stored in a variable?

A. shell

, B. check


C. text


D. capture_output


Answer: D


Rationale: The capture_output parameter tells Python to redirect standard output and

standard error into the CompletedProcess object. By setting this to True, developers can

access the result using the .stdout attribute. Without this parameter, the command output

would simply print to the console instead of being saved.


5. What is the result of opening a file in ‘a’ mode (append mode) and writing data to it?

A. The existing contents of the file are deleted and replaced


B. A new file is created only if the file does not already exist


C. The file is opened for reading and writing simultaneously


D. The new data is added to the end of the existing file content


Answer: D


Rationale: Append mode (‘a’) ensures that any data written to the file is placed at the very

end of the existing content. Unlike write mode (‘w’), it does not truncate or clear the file

before writing. This is the standard mode used for generating continuous logs in

automation workflows.

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