WGU D522 PYTHON FOR IT AUTOMATION COMPREHENSIVE
OA EXAM| PRACTICE QUESTIONS AND ANSWERS 2026/2027 |
VERIFIED ANSWERS PLUS RATIONALES | GRADED Q&A
COMPREHENSIVE STUDY GUIDE | LATEST 2027
1. A systems administrator is writing a script to parse basic system configurations. Which
built-in Python function should be used to collect string input directly from a system user
at the command line?
A. print()
B. input()
C. read()
D. sys.stdin()
Rationale: The input() function reads a line from the user interface as a standard string. It is
the primary built-in method for collecting command-line user inputs in Python script
automation.
2. An IT specialist needs to store a collection of server IP addresses in a variable. The
collection must maintain its insertion order and allow duplicate entries. Which Python data
type is most appropriate?
A. Set
B. Dictionary
C. List
D. Tuple
Rationale: A Python list is an ordered, mutable collection that permits duplicate elements,
making it ideal for managing sequential items like IP address lists where order matters and
duplicates may occur.
3. While reviewing an automation script, an engineer notices a variable declared as port =
8080. What is the fundamental data type of this variable?
A. Float
B. String
,C. Integer
D. Boolean
Rationale: Whole numbers without a decimal point are classified as integer (int) data types in
Python. Port numbers represented as whole digits fit this classification.
4. A developer wants to ensure that a set of network configuration constants cannot be
altered after initialization. Which immutable Python data structure should be selected?
A. List
B. Tuple
C. Dictionary
D. Bytearray
Rationale: Tuples are immutable sequence types in Python, meaning once defined, their
elements cannot be added, removed, or modified. This property ensures configuration
constants remain fixed during execution.
5. An administrator needs to evaluate whether a specific service status variable is set to
active before initiating a deployment script. Which conditional operator checks for strict
equality in Python?
A. =
B. ==
C. !=
D. is
Rationale: The double equal operator (==) evaluates whether the values of two operands are
equal. The single equal sign (=) is reserved for variable assignment.
6. A Python script processes a list of log files using a loop. Which control statement forces
the loop to terminate prematurely when an unrecoverable error flag is identified?
A. continue
B. pass
,C. break
D. return
Rationale: The break statement immediately terminates the loop in which it is executed,
jumping control to the statement following the loop structure.
7. An automation engineer wants to iterate through a list of network hostnames, skipping
the current iteration if a hostname starts with the prefix "test_". Which control statement
accomplishes this?
A. pass
B. break
C. skip
D. continue
Rationale: The continue statement skips the remaining code block inside the current loop
iteration and proceeds directly to the next iteration of the loop.
8. Which built-in Python module provides access to system-specific parameters and
command-line arguments passed to a script?
A. os
B. sys
C. platform
D. subprocess
Rationale: The sys module provides functions and variables used to manipulate different parts
of the Python runtime environment, including command-line arguments via sys.argv.
9. A DevOps engineer is writing a file cleanup script. Which built-in module is used to
interact directly with the host operating system, such as managing directories and checking
file paths?
A. os
B. sys
C. math
, D. shutil
Rationale: The os module provides a portable way of using operating system dependent
functionality, including file system navigation, directory creation, and path evaluation.
10. When opening a file in Python using the open() function, which mode string ensures
that new data is appended to the end of the file without overwriting existing content?
A. "r"
B. "w"
C. "a"
D. "x"
Rationale: Appending mode ("a") opens a file for writing, placing the file pointer at the end of
the file, thereby preserving existing contents and appending new data.
11. A script must read the contents of a configuration text file line by line into a list
structure. Which file object method achieves this directly?
A. read()
B. readline()
C. readlines()
D. extract()
Rationale: The readlines() method reads all remaining lines from a file object and returns
them as a list of strings, with each item representing a line.
12. What is the output of the Python expression 15 // 4?
A. 3.75
B. 3
C. 4
D. 3.0
OA EXAM| PRACTICE QUESTIONS AND ANSWERS 2026/2027 |
VERIFIED ANSWERS PLUS RATIONALES | GRADED Q&A
COMPREHENSIVE STUDY GUIDE | LATEST 2027
1. A systems administrator is writing a script to parse basic system configurations. Which
built-in Python function should be used to collect string input directly from a system user
at the command line?
A. print()
B. input()
C. read()
D. sys.stdin()
Rationale: The input() function reads a line from the user interface as a standard string. It is
the primary built-in method for collecting command-line user inputs in Python script
automation.
2. An IT specialist needs to store a collection of server IP addresses in a variable. The
collection must maintain its insertion order and allow duplicate entries. Which Python data
type is most appropriate?
A. Set
B. Dictionary
C. List
D. Tuple
Rationale: A Python list is an ordered, mutable collection that permits duplicate elements,
making it ideal for managing sequential items like IP address lists where order matters and
duplicates may occur.
3. While reviewing an automation script, an engineer notices a variable declared as port =
8080. What is the fundamental data type of this variable?
A. Float
B. String
,C. Integer
D. Boolean
Rationale: Whole numbers without a decimal point are classified as integer (int) data types in
Python. Port numbers represented as whole digits fit this classification.
4. A developer wants to ensure that a set of network configuration constants cannot be
altered after initialization. Which immutable Python data structure should be selected?
A. List
B. Tuple
C. Dictionary
D. Bytearray
Rationale: Tuples are immutable sequence types in Python, meaning once defined, their
elements cannot be added, removed, or modified. This property ensures configuration
constants remain fixed during execution.
5. An administrator needs to evaluate whether a specific service status variable is set to
active before initiating a deployment script. Which conditional operator checks for strict
equality in Python?
A. =
B. ==
C. !=
D. is
Rationale: The double equal operator (==) evaluates whether the values of two operands are
equal. The single equal sign (=) is reserved for variable assignment.
6. A Python script processes a list of log files using a loop. Which control statement forces
the loop to terminate prematurely when an unrecoverable error flag is identified?
A. continue
B. pass
,C. break
D. return
Rationale: The break statement immediately terminates the loop in which it is executed,
jumping control to the statement following the loop structure.
7. An automation engineer wants to iterate through a list of network hostnames, skipping
the current iteration if a hostname starts with the prefix "test_". Which control statement
accomplishes this?
A. pass
B. break
C. skip
D. continue
Rationale: The continue statement skips the remaining code block inside the current loop
iteration and proceeds directly to the next iteration of the loop.
8. Which built-in Python module provides access to system-specific parameters and
command-line arguments passed to a script?
A. os
B. sys
C. platform
D. subprocess
Rationale: The sys module provides functions and variables used to manipulate different parts
of the Python runtime environment, including command-line arguments via sys.argv.
9. A DevOps engineer is writing a file cleanup script. Which built-in module is used to
interact directly with the host operating system, such as managing directories and checking
file paths?
A. os
B. sys
C. math
, D. shutil
Rationale: The os module provides a portable way of using operating system dependent
functionality, including file system navigation, directory creation, and path evaluation.
10. When opening a file in Python using the open() function, which mode string ensures
that new data is appended to the end of the file without overwriting existing content?
A. "r"
B. "w"
C. "a"
D. "x"
Rationale: Appending mode ("a") opens a file for writing, placing the file pointer at the end of
the file, thereby preserving existing contents and appending new data.
11. A script must read the contents of a configuration text file line by line into a list
structure. Which file object method achieves this directly?
A. read()
B. readline()
C. readlines()
D. extract()
Rationale: The readlines() method reads all remaining lines from a file object and returns
them as a list of strings, with each item representing a line.
12. What is the output of the Python expression 15 // 4?
A. 3.75
B. 3
C. 4
D. 3.0