Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

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

Rating
-
Sold
-
Pages
57
Grade
A+
Uploaded on
07-02-2026
Written in
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

Institution
WGU D522
Course
WGU D522

Content preview

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 administrator needs to write a Python script that processes server hostnames. The
script must handle cases where a hostname might be missing (None) without crashing. Which
code snippet properly implements this error handling?

A.

Python

Copy

hostname = get_server_name()

print(hostname.upper())

B.

Python

Copy

hostname = get_server_name()

try:

print(hostname.upper())

except AttributeError:

print("No hostname provided")

``` [CORRECT]

,C.

```python

hostname = get_server_name()

if hostname is not "":

print(hostname.upper())

D.

Python

Copy

hostname = get_server_name()

print(hostname.upper() or "No hostname provided")

Correct Answer: B

Rationale: Option B correctly uses a try/except block to catch the AttributeError that occurs
when calling .upper() on None. This is the Pythonic way to handle potential None values when
the operation might fail. Option A crashes with AttributeError if hostname is None. Option C
checks for empty string but None is not an empty string—the condition passes and still crashes.
Option D uses short-circuit evaluation incorrectly; hostname.upper() executes first and raises
the exception before the or can evaluate.



Q2: A DevOps engineer is creating a virtual environment for a new automation project. Which
sequence of commands correctly sets up and activates a Python 3 virtual environment named
automation_env on a Linux system?

A. python -m venv automation_env then source automation_env/bin/activate [CORRECT]

B. pip install virtualenv automation_env then virtualenv activate

C. python3 -m virtualenv create automation_env then automation_env/Scripts/activate

D. venv create automation_env then ./automation_env/bin/activate

Correct Answer: A

,Rationale: The standard library venv module creates virtual environments: python -m venv
<name>. Activation on Linux/macOS uses source <name>/bin/activate (Windows uses
Scripts\activate). Option B incorrectly uses pip to install virtualenv without proper syntax.
Option C uses wrong module path (Scripts is Windows, not Linux). Option D omits the -m flag
required to run venv as a module.



Q3: [CODE ANALYSIS] What is the output of the following code snippet?

Python

Copy

import sys



def check_python_version():

version = sys.version_info

if version.major == 3 and version.minor >= 8:

return "Supported"

elif version.major == 3:

return "Legacy"

else:

return "Unsupported"



print(check_python_version())

Assuming the script runs on Python 3.11.4:

A. "Legacy"
B. "Unsupported"
C. "Supported" [CORRECT]
D. None

Correct Answer: C

, Rationale: sys.version_info returns a named tuple (major, minor, micro, releaselevel, serial).
Python 3.11.4 gives version.major=3, version.minor=11. The condition version.major == 3 and
version.minor >= 8 evaluates True (11 >= 8), returning "Supported". This pattern is common in
automation scripts checking for compatible Python versions before importing version-specific
modules like asyncio features or typing constructs.



Q4: A system administrator needs to process a list of IP addresses, removing duplicates while
preserving the original order of first appearance. Which Python code accomplishes this most
efficiently?

A.

Python

Copy

unique_ips = list(set(ip_list))

B.

Python

Copy

unique_ips = []

for ip in ip_list:

if ip not in unique_ips:

unique_ips.append(ip)

``` [CORRECT]



C.

```python

unique_ips = dict.fromkeys(ip_list).keys()

D.

Python

Copy

Written for

Institution
WGU D522
Course
WGU D522

Document information

Uploaded on
February 7, 2026
Number of pages
57
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

  • wgu d522
$16.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
EMPRESS254
1.0
(1)

Get to know the seller

Seller avatar
EMPRESS254 Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
6
Member since
6 months
Number of followers
0
Documents
646
Last sold
21 hours ago
Empress

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

1.0

1 reviews

5
0
4
0
3
0
2
0
1
1

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions