• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 13 pages
Exam (elaborations)

WGU D522 Python for IT Automation Objective Assessment 2026/2027 – Questions and Answers | 100% Verified | Detailed Rationales – Pass Guaranteed – A+ Graded

Document preview thumbnail
Preview 2 out of 13 pages

WGU D522 OA 2026/2027 – Questions with Answers | 100% Correct | Python Programming, IT Automation, Scripting, File Management | Graded A+ Verified | APIs, Error Handling, Version Control, Task Automation | Detailed Rationales | Verified Correct Answers – Pass Guaranteed – Instant Download

Content preview

WGU • IT AUTOMATION • PYTHON

WGU D522 Objective Assessment
(New 2026/2027 Update) Python for IT Automation
2026/2027 ACTUAL EXAM TEST BANK
WITH REAL EXAM QUESTIONS AND
100% CORRECT VERIFIED ANSWERS (GUARANTEED PASS!!)
Aligned to WGU Content Outline • IT Automation Level



A+ 5 100%

QUESTIONS SECTIONS RATIONALES
VERIFIED COMPLETE INCLUDED


CATEGORIES
■ SECTION 1 — Python Fundamentals & Syntax
■ SECTION 2 — Data Structures & File Handling
■ SECTION 3 — Modules, Packages, Errors & Debugging
■ SECTION 4 — Automation Scripting (OS, Subprocess, Regex, Networking)
■ SECTION 5 — Practical IT Automation, Security & Best Practices


STUVIAACTUALEXAM
Aligned to WGU D522 Python for IT Automation • 2026/2027

, SECTION 1: PYTHON FUNDAMENTALS & SYNTAX

Q1. An IT automation script needs to store a server hostname that will never change during execution. A junior administrator wrote: server
= 'web01.example.com'. A peer review asks whether a different construct would better communicate intent. Which approach most clearly
signals a constant value in Python while remaining conventional for scripts?
A. Use a tuple containing the string and never index it
B. Wrap the string in a frozenset before assignment
C. Name the variable in uppercase (SERVER = 'web01.example.com') to signal a constant by convention
D. Declare the variable with the const keyword before the name
Correct Answer: C
Rationale: Python has no const keyword. The community convention is to use UPPER_SNAKE_CASE names for values that should not be reassigned,
signaling intent to other maintainers.

Q2. A script processes log lines and must decide whether a line contains the substring 'ERROR'. The developer writes: if 'ERROR' in line:
... What is the primary advantage of using the in operator with a string in this context?
A. It always performs a case-insensitive search without extra flags
B. It converts the line to a list of characters before searching
C. It raises an exception if the substring is missing, forcing explicit handling
D. It returns True if the substring exists anywhere in the string, providing a clear and efficient membership test
Correct Answer: D
Rationale: The in operator for strings performs a substring membership test and returns a Boolean. It is the idiomatic, readable way to check for presence of
text in a line.

Q3. An automation script must iterate over a list of hostnames and print each one with its 1-based index for an audit report. The developer
wants both the index and the value. Which construct is the most Pythonic solution?
A. Manual counter variable incremented inside a plain for loop only
B. for i, host in enumerate(hosts, start=1): print(i, host)
C. Using range(len(hosts)) and indexing without enumerate
D. Converting the list to a dictionary of indexes before looping
Correct Answer: B
Rationale: enumerate pairs each item with an index. The start parameter sets the first index to 1, which matches human-readable numbering in reports.

Q4. A function is defined as def connect(host, port=22, timeout=30):. A caller invokes connect('db01', timeout=10). Which values do port
and timeout receive?
A. port=22 (default) and timeout=10 (explicit keyword argument)
B. port=10 and timeout=22 because positional order is forced
C. Both remain unset and raise TypeError
D. port=10 and timeout=30
Correct Answer: A
Rationale: Keyword arguments can be supplied out of order. host is positional, timeout is overridden by name, and port keeps its default of 22.

Q5. A script needs to build a multi-line configuration string that includes variable values for hostname and port. The developer wants
readable interpolation. Which approach is preferred in modern Python for clarity and safety?
A. Concatenating with + and str() calls only
B. Relying solely on the % operator with a single tuple
C. Joining a list of characters one by one
D. Using an f-string such as config = f'host={hostname}\nport={port}'
Correct Answer: D
Rationale: f-strings provide concise, readable interpolation of expressions inside curly braces and are the preferred modern approach for this kind of string
building.

Q6. An automation task must run a block of code at least once and then repeat while a connection flag remains True. Which loop structure
best expresses 'execute once, then continue while condition holds'?
A. A for loop over an infinite range only
B. A while True loop with a conditional break after the first iteration, or an explicit do-while simulation using while with a trailing check
C. A plain for loop over a fixed list of length one
D. Using map() with a lambda that never terminates
Correct Answer: B
Rationale: Python lacks a built-in do-while. The standard pattern is while True: ...; if not condition: break, which guarantees one execution and then continues
while the condition remains true.

Q7. A developer writes: result = . In Python 3, what is the type and approximate value of result?

STUVIAACTUALEXAM | Page 2 of 13

Document information

Uploaded on
September 12, 2026
Number of pages
13
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$16.49

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

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
STUVIAACTUALEXAMS
3.5
(176)
Sold
1342
Followers
209
Items
10272
Last sold
1 hour ago



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