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
Examen

WGU D522 Python for IT Automation ACTUAL OBJECTIVE ASSESSMENT PRACTICE 2026/2027 | Verified Code-Centric & Scenario-Based Questions and Answers | Grade A Target | Pass Guaranteed

Puntuación
-
Vendido
-
Páginas
72
Grado
A+
Subido en
07-02-2026
Escrito en
2025/2026

WGU D522 Python for IT Automation ACTUAL OBJECTIVE ASSESSMENT PRACTICE 2026/2027 | Verified Code-Centric & Scenario-Based Questions and Answers | Grade A Target | Pass Guaranteed

Institución
WGU D522
Grado
WGU D522

Vista previa del contenido

WGU D522 Python for IT Automation
ACTUAL OBJECTIVE ASSESSMENT PRACTICE
2026/2027 | Verified Code-Centric &
Scenario-Based Questions and Answers |
Grade A Target | Pass Guaranteed
Section 1: Python Foundations & Scripting Environment (Questions 1-10)

Q1: An IT automation script needs to process server hostnames that follow the pattern web-
01.prod.company.com. Which Python data structure is most appropriate for storing these
hostnames when the primary operations will be checking for membership (is this server in the
pool?) and ensuring no duplicates exist?

A. hostnames = ["web-01.prod.company.com", "web-02.prod.company.com"]
B. hostnames = ("web-01.prod.company.com", "web-02.prod.company.com")
C. hostnames = {"web-01.prod.company.com", "web-02.prod.company.com"} [CORRECT]
D. hostnames = "web-01.prod.company.com,web-02.prod.company.com"

Correct Answer: C

Rationale: A set (C) is the optimal choice for membership testing and deduplication. Sets
provide O(1) average-case lookup time for membership tests (in operator) versus O(n) for lists
and tuples. Sets inherently prevent duplicates, which is critical for server pools.

• Option A (list) allows duplicates and has slower membership testing.

• Option B (tuple) is immutable and also has O(n) membership testing.

• Option D (string) would require parsing and cannot represent multiple distinct
hostnames as separate elements without additional processing.

Pythonic best practice: Use sets when uniqueness and membership testing are primary
concerns, as in load balancer pools, firewall rule sets, or inventory management.



Q2: A system administrator writes the following script to check disk usage. What will be the
output?

,Python

Copy

#!/usr/bin/env python3

import sys



def check_disk(usage):

if usage > 90:

return "CRITICAL"

elif usage > 75:

return "WARNING"

return "OK"



try:

disk_usage = int(sys.argv[1])

status = check_disk(disk_usage)

print(f"Disk status: {status}")

except (IndexError, ValueError):

print("Usage: script.py <disk_usage_percent>")

sys.exit(1)

When executed as python3 script.py 85, what is printed?

A. Disk status: CRITICAL
B. Disk status: WARNING [CORRECT]
C. Disk status: OK
D. Usage: script.py <disk_usage_percent>

Correct Answer: B

Rationale: The value 85 is passed as a command-line argument, converted to integer 85. In
check_disk():

, • 85 > 90 is False, so not CRITICAL

• 85 > 75 is True, so returns "WARNING"

The elif condition is satisfied first, and the function returns immediately. The try/except block
handles the case where no argument is provided (IndexError) or a non-integer is provided
(ValueError).

• Option A would require > 90.

• Option C would require ≤ 75.

• Option D would trigger if no argument or non-integer was provided.

Best practice: Using sys.exit(1) indicates error status to calling processes/shell scripts, enabling
proper automation workflow handling.



Q3: [Multiple Response] Which of the following are valid ways to create a virtual environment
for Python 3.9+ and activate it on a Linux system? (Select all that apply.)

A. python3 -m venv /opt/automation/venv then source /opt/automation/venv/bin/activate
[CORRECT]
B. virtualenv /opt/automation/venv then source /opt/automation/venv/bin/activate [CORRECT]
C. python3 -m virtualenv /opt/automation/venv then . /opt/automation/venv/bin/activate
[CORRECT]
D. venv /opt/automation/venv then source /opt/automation/venv/Scripts/activate

Correct Answers: A, B, C

Rationale:

• A: The standard library venv module is the modern, recommended approach (PEP 405).
Activation uses source (or .) on the activate script in bin/ (Linux/macOS).

• B: The third-party virtualenv package remains valid and widely used, especially for older
Python versions or advanced features.

• C: Running virtualenv as a module via -m is valid syntax and equivalent to standalone
virtualenv command.

D is incorrect because:

• venv is not a standalone command; it must be called as python3 -m venv

• Scripts/activate is the Windows path; Linux uses bin/activate

, Operational note: Virtual environments isolate dependencies, preventing conflicts between
system Python packages and automation script requirements. Always document
requirements.txt and venv creation in deployment playbooks.



Q4: A log processing script uses the following pattern. What potential issue exists?

Python

Copy

def process_logs(log_files):

results = []

for file in log_files:

f = open(file, 'r')

data = f.read()

results.append(parse_log(data))

f.close()

return results

A. The script will fail if log_files contains non-existent files
B. File handles may not be closed if parse_log() raises an exception [CORRECT]
C. The results list will contain duplicate entries
D. Reading entire files into memory is inefficient for large logs

Correct Answer: B

Rationale: While D is technically true (streaming/lazy reading is better for large files), B
represents a critical resource leak bug. If parse_log(data) raises an exception, f.close() never
executes, leaving file descriptors open. On long-running automation jobs processing thousands
of logs, this causes "too many open files" errors (OSError: [Errno 24]).

The Pythonic solution uses context managers:

Python

Copy

with open(file, 'r') as f:

Escuela, estudio y materia

Institución
WGU D522
Grado
WGU D522

Información del documento

Subido en
7 de febrero de 2026
Número de páginas
72
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

$16.49
Accede al documento completo:

¿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

Conoce al vendedor
Seller avatar
EMPRESS254
1.0
(1)

Conoce al vendedor

Seller avatar
EMPRESS254 Chamberlain College Of Nursing
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
6
Miembro desde
6 meses
Número de seguidores
0
Documentos
646
Última venta
19 horas hace
Empress

One stop shop for all all study materials, Study guides,Exams and all assignments and homeworks.

1.0

1 reseñas

5
0
4
0
3
0
2
0
1
1

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