• 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 3 out of 17 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 3 out of 17 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

STATE LICENSURE EXAM PREP




WGU D522 Objective Assessment
(New 2026/2027 Update)
Python for IT Automation
2026/2027 ACTUAL EXAM TEST BANK
WITH REAL EXAM QUESTIONS AND A+
100% CORRECT VERIFIED ANSWERS
(GUARANTEED PASS!!)

Aligned to WGU Content Outline • IT Automation Level




A+ QUESTIONS 5 SECTIONS 100%
VERIFIED COMPLETE RATIONALES

CATEGORIES

SECTION 1 — Python Fundamentals, Syntax & Control Flow

SECTION 2 — Data Structures & Collections

SECTION 3 — File I/O, CSV, JSON & Serialization

SECTION 4 — Regular Expressions, Strings & OS Interaction

SECTION 5 — Networking, Error Handling, Libraries & Automation




STUVIAACTUALEXAM

,SECTION 1: Python Fundamentals, Syntax & Control Flow
Q1. A junior automation engineer writes a script that must process a fixed list of 50 server hostnames. The engineer needs the loop to
execute exactly once for each hostname. Which loop construct is the most appropriate and Pythonic choice for this scenario?
A. A while True loop that increments a counter until it reaches 50
B. A for loop that iterates directly over the list of hostnames
C. A recursive function that calls itself 50 times
D. A do-while loop using the do keyword
Correct Answer: B
Rationale:
When the number of iterations is known and the collection already exists, a for-loop over the collection is the clearest and most idiomatic solution. while True
requires manual termination, recursion is inefficient and risks stack overflow, and Python has no do-while statement.

Q2. A script contains the following statement: result = . The automation engineer expects an integer result but receives a float. Which
operator should be used instead to obtain floor division?
A. The double-slash // operator
B. The double-star ** operator
C. The single slash / operator
D. The percent % operator
Correct Answer: A
Rationale:
The // operator performs floor division and returns an integer result (truncated toward negative infinity). The / operator always returns a float in Python 3, ** is
exponentiation, and % is the modulo operator.

Q3. An IT automation script must decide whether to reboot a device based on three conditions: the device is reachable, its uptime exceeds
30 days, and no critical processes are running. Which Boolean expression correctly combines these requirements?
A. reachable or uptime > 30 or not critical_procs
B. reachable and uptime > 30 or not critical_procs
C. reachable and uptime > 30 and not critical_procs
D. not reachable and uptime > 30 and critical_procs
Correct Answer: C
Rationale:
All three conditions must be true simultaneously, so the logical AND operator is required. Using OR would allow the reboot if any single condition is true, which
is incorrect for this policy.

Q4. A developer needs to define a block of code that belongs to an if statement. The editor shows an IndentationError when the script is
run. What is the fundamental Python rule that was violated?
A. Python requires curly braces { } to delimit every code block
B. Python requires the keyword begin to start a block
C. Python uses consistent indentation (spaces or tabs) to define code blocks
D. Python ignores whitespace and only cares about semicolons
Correct Answer: C
Rationale:
Python uses indentation level, not braces or keywords, to determine the extent of a code block. Mixing tabs and spaces or inconsistent indentation produces
an IndentationError.

Q5. A monitoring script must keep polling a service until the service returns an HTTP 200 status or 12 attempts have been made. Which
control-flow pattern correctly implements this requirement?
A. A for loop over range(12) that always exits after exactly 12 iterations regardless of status
B. A while loop that continues while status != 200 and attempts < 12
C. An infinite loop with no exit condition
D. A recursive call that never checks the attempt counter
Correct Answer: B
Rationale:
A while loop whose condition tests both the desired status and the attempt limit implements the classic 'retry until success or max attempts' pattern used in
automation.




STUVIAACTUALEXAM • Page 2

, SECTION 1: Python Fundamentals, Syntax & Control Flow
Q6. Inside a function that processes device inventory, a variable named count is assigned a value. Later in the same function the engineer
tries to read a variable named Count and receives a NameError. What is the most likely cause?
A. The variable went out of scope because it was declared inside an if block
B. Python variable names are case-sensitive
C. Python automatically converts all names to lowercase
D. The NameError is caused by missing parentheses after the variable
Correct Answer: B
Rationale:
Python identifiers are case-sensitive; count and Count are two distinct names. Scope issues would produce UnboundLocalError or NameError only if the name
was never bound in that scope.

Q7. A script must execute a block of cleanup code whether or not an earlier operation succeeded. Which language construct guarantees
that the cleanup block runs?
A. A finally clause attached to a try statement
B. An else clause attached to a for loop
C. A continue statement inside a while loop
D. A pass statement at the end of the function
Correct Answer: A
Rationale:
The finally clause of a try/except/finally statement is guaranteed to execute on the way out of the try block, whether an exception occurred or not, making it
ideal for resource cleanup.

Q8. An engineer writes: if status_code = 200: print('OK'). The script raises a SyntaxError. What is the mistake?
A. The comparison operator == should be used instead of the assignment operator =
B. The print statement needs parentheses in Python 2 only
C. status_code must be declared with a type annotation
D. The colon after the if condition is illegal
Correct Answer: A
Rationale:
A single equals sign is assignment; a conditional test requires the equality operator ==. Using assignment inside an if header is a syntax error in Python.

Q9. A function is defined with a default argument: def connect(host, timeout=30). A later call is written as connect(timeout=10,
'192.168.1.1'). What error occurs?
A. SyntaxError because default arguments are illegal
B. NameError because host is undefined
C. ValueError because timeout cannot be changed
D. TypeError because a positional argument follows a keyword argument
Correct Answer: D
Rationale:
Once a keyword argument appears in a call, every subsequent argument must also be keyword-style. Placing a positional argument after a keyword argument
raises TypeError.

Q10. A script uses the expression x = y = z = 0. Which statement correctly describes the effect?
A. Only z is assigned the value 0; x and y remain unbound
B. The expression is illegal and raises SyntaxError
C. x, y, and z all become references to the same integer object 0
D. Each variable receives a distinct copy of the integer 0
Correct Answer: C
Rationale:
Chained assignment binds all names on the left to the single object on the right. Because integers are immutable, later rebinding of one name does not affect
the others.




STUVIAACTUALEXAM • Page 3

Document information

Uploaded on
September 10, 2026
Number of pages
17
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$16.99

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