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
86
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 (10 Questions)



Q1: A system administrator needs to create a Python script that processes server hostnames.
The script should accept a variable number of hostname arguments and validate that each
contains only alphanumeric characters and hyphens. Which function signature and validation
approach is most Pythonic?

A.

Python

Copy

def validate_hosts(host_list):

for host in host_list:

if not host.isalnum():

return False

return True

B.

Python

Copy

def validate_hosts(*hosts):

return all(h.replace('-', '').isalnum() for h in hosts) [CORRECT]

C.

Python

,Copy

def validate_hosts(hosts):

valid = True

for i in range(len(hosts)):

if not re.match(r'^[a-zA-Z0-9-]+$', hosts[i]):

valid = False

return valid

D.

Python

Copy

def validate_hosts(**hosts):

return [h for h in hosts.values() if h.isalnum()]

Correct Answer: B
Rationale: Option B demonstrates Pythonic practices: using *hosts for variadic arguments
(accepting any number of positional arguments), generator expression with all() for efficient
short-circuit evaluation, and str.replace() combined with isalnum() for validation. The all()
function stops at the first False, optimizing performance. Option A fails because isalnum()
rejects hyphens, which are valid in hostnames. Option C works but is verbose; the regex is
unnecessary when string methods suffice, and manual indexing with range(len()) is unPythonic.
Option D incorrectly uses **kwargs (for keyword arguments) and returns a list instead of a
boolean, while also failing to handle hyphens.



Q2: A DevOps engineer is writing a configuration parser. The code needs to handle missing
configuration keys gracefully. Which implementation best follows Python exception handling
best practices?

A.

Python

Copy

def get_config_value(config, key):

, try:

return config[key]

except:

return None

B.

Python

Copy

def get_config_value(config, key):

if key in config:

return config[key]

else:

raise KeyError(f"Key {key} not found")

C.

Python

Copy

def get_config_value(config, key):

try:

return config[key]

except KeyError:

return config.get('default', None) [CORRECT]

except TypeError:

raise ValueError("Config must be a dictionary")

D.

Python

Copy

def get_config_value(config, key):

, return config[key] or None

Correct Answer: C
Rationale: Option C demonstrates proper exception handling: catching specific exceptions
(KeyError, TypeError) rather than bare except, providing fallback behavior for missing keys, and
raising descriptive errors for invalid input types. This follows EAFP (Easier to Ask Forgiveness
than Permission) and maintains clear error boundaries. Option A uses bare except which
catches KeyboardInterrupt and SystemExit, making the script unkillable—an anti-pattern.
Option B violates the principle of least surprise by raising an exception for a missing key when a
default return would be more useful; it also uses LBYL (Look Before You Leap) which is less
Pythonic than EAFP for this case. Option D doesn't handle the case where key doesn't exist
(raises KeyError) and misuses or logic.



Q3: An automation script needs to process a list of server dictionaries, extracting only servers in
the "production" environment with status "running". Which list comprehension is correct?

Given data:

Python

Copy

servers = [

{'name': 'web01', 'env': 'production', 'status': 'running'},

{'name': 'web02', 'env': 'staging', 'status': 'running'},

{'name': 'db01', 'env': 'production', 'status': 'stopped'}

]

A.

Python

Copy

prod_running = [s for s in servers if s['env'] == 'production'

and s.status == 'running']

B.

Python

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
86
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

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