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 Objective Assessment Exam Actual Exam 2026/2027 – Complete Exam-Style Questions | Detailed Rationales – Pass Guaranteed – A+ Graded

Rating
-
Sold
-
Pages
37
Grade
A+
Uploaded on
05-06-2026
Written in
2025/2026

WGU D522 Python for IT Automation OA Exam Actual Exam 2026/2027 – Real-Style Questions with Answers | 100% Correct | Python Syntax, Data Types, Control Structures, Functions, File Handling | Graded A+ Verified | Regular Expressions, APIs, Web Scraping, Automation Scripts, Debugging | Detailed Rationales | Verified Correct Answers – Pass Guaranteed – Instant Download

Show more Read less
Institution
WGU D522
Course
WGU D522

Content preview

WGU D522 Objective Assessment (New 2026/2027 Update) Python for IT Automation | Qs & As| Grade A| 100% Correct (Verified Answers) 2026/2027 | Page 1 | Passing Score: 80%




WESTERN GOVERNORS UNIVERSITY

WGU D522 Objective Assessment (New 2026/2027 Update)
Python for IT Automation | Qs & As| Grade A| 100% Correct (Verified Answers
2026/2027 Edition | Official Exam 2026/2027




75 80% N/A
QUESTIONS PASSING SCORE RECERTIFICATION




TABLE OF CONTENTS



Section 1 Python Fundamentals and Syntax Q1-15


Section 2 Data Structures and Operations Q16-30


Section 3 Control Flow and Functions Q31-45


Section 4 File Handling and Exception Management Q46-60


Section 5 Automation Scripts and Libraries Q61-75




Instructions: Select the single best answer for each question. This exam is designed for WGU D522 Python for IT Automation certification
preparation. Passing score: 80% (60 questions correct).




WGU D522 Python for IT Automation -- 2026/2027 | Passing Score: 80% | Page 1 of 37

, SECTION 1 | Python Fundamentals and Syntax | Q1-Q15 | WGU D522 Python for IT Automation 2026/2027


Q1 Question 1 of 75
Q1. A junior developer is writing a Python script and needs to store a value that will not
change during execution, such as the maximum number of login attempts allowed. The
developer writes attempt_count = 5 at the top of the module. In Python, what is the
conventional way to indicate this value should not be reassigned?
A. Declare it as ATTEMPT_COUNT = 5 using all uppercase letters to signal it is a constant
B. Use the const keyword before the variable name like const attempt_count = 5
C. Write the value inside a frozen dictionary and reference it by key
D. Assign it inside a function decorated with @immutable

Correct Answer: A
Rationale:
Python has no const keyword; the convention of using ALL_CAPS signals intent to other developers that the value
should not be changed. Option B describes a language feature that does not exist in Python, and options C and D are
fabricated constructs.




Q2 Question 2 of 75
Q2. A data analyst runs a Python script and encounters a NameError on a variable that was
defined inside an if block. The variable was only assigned when the condition evaluated to
True. What is the most likely cause of this error?
A. Variables assigned inside an if block are scoped to that block and do not exist outside it in
Python
B. The variable name contained a hyphen which is not allowed in Python identifiers
C. Python requires all variables to be declared at the top of the file before any conditional logic
D. The if block created a new namespace that overrides the global namespace automatically

Correct Answer: A
Rationale:
In Python, variables assigned inside conditional blocks are function-scoped, not block-scoped. If the condition is False,
the variable is never created, causing a NameError when referenced later. Option B is incorrect because hyphens are
not allowed in identifiers but that is a different issue.




WGU D522 Python for IT Automation -- 2026/2027 | Passing Score: 80% | Page 2 of 37

,Q3 Question 3 of 75
Q3. An IT specialist needs to convert a user-entered string representing a port number into an
integer for a network configuration script. The user might enter non-numeric text accidentally.
What is the best approach to safely perform this conversion?
A. Wrap the int() conversion in a try/except block to catch ValueError if the string is not numeric
B. Use the str.isnumeric() method first and then call int() without any exception handling
C. Call int() directly and rely on the default Python error message to inform the user
D. Use float() instead of int() since it accepts a wider range of inputs

Correct Answer: B
Rationale:
While checking isnumeric() first seems reasonable, it does not handle edge cases like negative signs or whitespace.
Using try/except with int() is the Pythonic approach that handles all invalid conversions cleanly. Option C is a poor
approach, and option D would not produce the correct integer type.




Q4 Question 4 of 75
Q4. A developer writes a script that uses the expression 17 // 5 and expects the result to be
3.4. However, the output is 3. What does the // operator do in Python?
A. It performs floor division, returning the largest integer less than or equal to the exact quotient
B. It performs integer division only when both operands are integers, otherwise it returns a float
C. It rounds the result of normal division to the nearest integer using standard rounding rules
D. It performs modulo division and returns the remainder of the operation

Correct Answer: B
Rationale:
The // operator performs floor division, which always rounds down to the nearest integer. This is different from
truncation toward zero; for negative results, floor division yields a more negative number. Option D confuses // with the
modulo operator %.




WGU D522 Python for IT Automation -- 2026/2027 | Passing Score: 80% | Page 3 of 37

, Q5 Question 5 of 75
Q5. A systems engineer is writing a Python script that concatenates a string and an integer
value in a print statement: print('Server count: ' + 5). This raises a TypeError. What is the
correct way to fix this?
A. Convert the integer to a string using str() before concatenation: print('Server count: ' + str(5))
B. Use the plus operator with a type hint to tell Python to auto-convert: print('Server count: ' + int(5))
C. Declare the integer as a string from the beginning by wrapping it in single quotes inside the expression
D. Use the concat() built-in function which handles mixed types automatically

Correct Answer: A
Rationale:
Python does not allow implicit concatenation between strings and integers. The str() function explicitly converts the
integer to its string representation. Option B uses int() which would cause the same error, and options C and D
reference nonexistent functions.




Q6 Question 6 of 75
Q6. A programmer is debugging a script and discovers that the expression True + True
evaluates to 2 in Python. Which Python feature explains this behavior?
A. The bool type is a subclass of int where True equals 1 and False equals 0
B. Python automatically casts boolean values to integers whenever the plus operator is used
C. The plus operator has a special overload for boolean operands that returns their sum as an integer
D. True is stored internally as the integer 2 in Python and False as 1

Correct Answer: A
Rationale:
In Python, the bool class inherits from int, making True equivalent to 1 and False equivalent to 0. This design allows
boolean values to participate in arithmetic operations naturally. Options B and C describe mechanisms that do not exist
in Python.




WGU D522 Python for IT Automation -- 2026/2027 | Passing Score: 80% | Page 4 of 37

Written for

Institution
WGU D522
Course
WGU D522

Document information

Uploaded on
June 5, 2026
Number of pages
37
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$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
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 University Of California - Los Angeles (UCLA)
Follow You need to be logged in order to follow users or courses
Sold
1086
Member since
3 year
Number of followers
204
Documents
7984
Last sold
11 hours ago
Actual Exam

STUVIAACTUALEXAMS is a trusted exam-success delivering accurate, verified, and exam-focused study materials that include real exam-style questions, correct answers, and clear, easy-to-follow rationales, all professionally organized to save time, eliminate guesswork, reduce stress, boost confidence, and help students secure top grades and pass their exams on the first attempt with certainty and ease.

3.5

143 reviews

5
58
4
24
3
22
2
11
1
28

Recently viewed by you

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