I T A U T OM AT I ON & P R OG R A M M I N G · OB JEC T I V E A S S ES S M EN T
WGU D522 Final Exam Guide
Python for IT Automation — Complete
New 2026/2027 Update · Final Exam Guide · Qs & As · Grade A · 100% Correct (Verified Answers) · 2026/2027
50 Questions Full Rationales Verified Answers
50
QUE STI ONS
5
SE CTI ONS
100%
R AT I O N A L E S
WHAT T HIS C OVE R S
01 Python Syntax, Variables & Data Types 10 Questions
02 Control Flow, Loops & Functions 10 Questions
03 Lists, Tuples, Dictionaries & Sets 10 Questions
04 Strings, Files & Exception Handling 10 Questions
05 Modules, Scripting & Automation Workflows 10 Questions
AB OUT T H I S AS S E S S ME NT
This assessment is an original study aid developed for independent Python and IT automation review. Every code
example, option, and rationale was newly written for this edition and reflects core scripting concepts from syntax and
control flow through modules and automation workflows. It is intended to support self-paced study, coding drills, and
exam-preparation review.
PA S S I N G S C O R E LE VE L F O R M AT
75% Application / Analysis Multiple Choice
S T UVI A ACT UAL E X AM Pa g e 1
, SECTION 01 — PYTHON SYNTAX, VARIABLES & DATA TYPES
Q1. An intern writes a script to track server inventory and names a variable '2nd_value' to hold the second
disk's size. When the script runs, the interpreter immediately rejects the line before doing anything else.
Why does Python reject this variable name?
A. Identifiers in Python must be written entirely in lowercase letters
B. Variable names may not contain the underscore character anywhere
C. Identifiers cannot begin with a digit under Python's naming rules
D. Python reserves names containing the word 'value' for built-in use
Correct Answer: C
Rationale: Python identifiers may contain letters, digits, and underscores but must start with a letter or underscore, so
2nd_value is illegal regardless of its meaning. Renaming it disk_two or _second_value resolves the error immediately.
Q2. A trainee writes the expression in a capacity-planning script and expects the integer 3, planning to
store the result in a whole-number column. The output surprises the trainee. What does this expression
actually produce in Python 3?
A. 3, because division between two integers truncates the remainder
B. An error, because the slash operator cannot combine two integers
C. 3.0, because integer division rounds to the nearest even value
D. 3.5, because the single slash always performs true division
Correct Answer: D
Rationale: In Python 3 the single slash is true division and always yields a float, so gives 3.5. Truncating division
requires the floor-divide operator, written as two slashes, which would return 3 here.
Q3. A script reads the string '7.5' from a configuration file and the developer calls int() on it to use the value
as a retry count. The program crashes at that line during testing. What is the correct explanation of this
failure?
A. int() succeeds but silently rounds the value down to 7
B. int() raises a ValueError because the string holds a decimal point
C. int() converts only values read from numeric file handles
D. int() returns the string unchanged because quotes block conversion
Correct Answer: B
Rationale: The int constructor accepts only strings that look like whole numbers, so int('7.5') raises ValueError instead
of truncating. The correct conversion is float('7.5'), optionally followed by int() to drop the fraction deliberately.
STUVIA ACTUAL EXAM · Page 2
, Q4. A script prints a status line for a monitoring dashboard, and the developer wants the two words joined
by a dash instead of the default single space: the call is print('disk', 'full', sep='-'). What exactly appears on
the console?
A. disk-full
B. disk full
C. disk-full-
D. diskfull
Correct Answer: A
Rationale: The sep parameter sets the string inserted between arguments, so the dash replaces the default space and the
console shows disk-full. With no sep argument, print would insert its default single space instead.
Q5. An automation script must skip empty descriptions read from a spreadsheet. The developer writes a
condition using the description alone, relying on Python's truthiness rules for strings. What does an empty
string evaluate to in a Boolean context?
A. True, because an empty string is still a valid object
B. None, because emptiness is a special third state
C. False, because empty sequences are treated as falsy
D. It raises an error, because strings cannot convert to Boolean
Correct Answer: C
Rationale: Python treats empty sequences, including the empty string, empty list, and empty tuple, as falsy, so bool('')
returns False and the condition skips the row. Any non-empty string is truthy, which is why the shortcut works reliably.
Q6. A script prompts an operator for the number of servers with the line count = input('How many servers?
') and then multiplies count by 4 to estimate ports. The multiplication produces unexpected output instead
of a number. What is the cause?
A. input() discards numeric characters and keeps only text labels
B. input() returns a float that must be rounded before use
C. input() returns an integer only when the prompt ends with a question mark
D. input() returns a string, so multiplication repeats rather than computes
Correct Answer: D
Rationale: In Python 3, input() always returns a str, so multiplying a string by an integer repeats the text that many
times instead of performing arithmetic. Wrapping the call in int() converts the entry to a real number before
multiplication.
STUVIA ACTUAL EXAM · Page 3