Objective Assessment Exam 2025/2026 –
Questions with Correct Detailed Answers and
Rationales (100% Guaranteed Pass)
This 2025/2026 updated exam for WGU D522 Python for IT Automation includes 50 multiple-
choice questions on Python fundamentals, scripting, automation, file I/O, data structures,
functions, modules, error handling, and IT applications. Questions are scenario-based, with four
options, the correct answer in RED, and detailed rationales with code snippets, clinical/IT
implications, and exam tips for 100% pass rate.
Question 1: What is the output of print("Hello, World!") in Python?
A. Error
B. Hello, World!
C. Hello World!
D. None
Correct Answer: B. Hello, World!
Rationale: The print() function outputs the string to the console. The comma adds a space.
Implication: Basic output for scripts. Exam Tip: print() always outputs to stdout.
Question 2: Which data type is immutable in Python?
A. List
B. Dictionary
C. Tuple
D. Set
Correct Answer: C. Tuple
Rationale: Tuples cannot be changed after creation, unlike lists (mutable). Implication: Use
tuples for fixed data in automation configs. Exam Tip: Remember: strings, tuples immutable;
lists, dicts mutable.
Question 3: What is the result of 5 // 2 in Python?
A. 2.5
B. 3
,C. 2
D. 7
Correct Answer: C. 2
Rationale: Floor division returns the integer part of quotient (2). Implication: Useful for file
sizing in IT scripts. Exam Tip: // for integer division, / for float.
Question 4: How do you define a function in Python?
A. func my_function():
B. def my_function():
C. function my_function():
D. define my_function():
Correct Answer: B. def my_function():
Rationale: "def" keyword defines functions; colon starts body. Implication: Modular code for
automation tasks. Exam Tip: Indentation defines scope.
Question 5: What does len([1, 2, 3]) return?
A. 3
B. 1
C. 6
D. Error
Correct Answer: A. 3
Rationale: len() returns the number of elements in a list. Implication: Count items in logs.
Exam Tip: len() works on lists, strings, dicts.
Question 6: What is the output of print(2 + 3 * 4)?
A. 20
B. 14
C. 5
D. 12
Correct Answer: B. 14
Rationale: PEMDAS: multiplication first (3*4=12), then addition (2+12=14). Implication:
Order matters in calculations. Exam Tip: * and / before + and -.
Question 7: Which is a Python dictionary?
A. [1, 2, 3]
B. {"key": "value"}
C. (1, 2, 3)
D. {1, 2, 3}
, Correct Answer: B. {"key": "value"}
Rationale: Dictionaries use key-value pairs with curly braces. Implication: Store configs in IT
scripts. Exam Tip: {} for dict and set; distinguish by colon.
Question 8: What is the result of "hello" + "world"?
A. helloworld
B. hello world
C. Error
D. [hello, world]
Correct Answer: A. helloworld
Rationale: String concatenation joins without space. Implication: Build file paths. Exam tip: +
for strings; , for print with space.
Question 9: What error occurs if you run code with undefined variable?
A. SyntaxError
B. NameError
C. TypeError
D. ValueError
Correct Answer: B. NameError
Rationale: NameError for undefined names. Implication: Debug scripts. Exam tip: NameError
– variable not defined.
Question 10: How do you read a file in Python?
A. open("file.txt", "r").read()
B. read("file.txt")
C. file.open("r")
D. f = open("file.txt"); f.read()
Correct Answer: D. f = open("file.txt"); f.read()
Rationale: Open in read mode, read content; close after. Implication: Log parsing in IT. Exam
tip: Always close files with f.close().
Question 11: What is the output of print(range(3))?
A. 0 1 2
B. range(0, 3)
C. [0, 1, 2]
D. 3
Correct Answer: B. Range(0, 3)