WGU D522 (WEN1) Task 1 Performance Assessment
— Full Practice Exam with correct answers and
rationales updated 2026
Section 1: Python Fundamentals for IT Automation (Questions 1–30)
1. What is the output of the following code?
python
Copy
Download
devices = ["router01", "switch01", "modem01", "gateway01", "printer01"]
print(devices[-1])
A. router01
B. printer01
C. gateway01
D. IndexError
Answer: B
Rationale: Negative indexing in Python allows access from the end of a sequence. -1 refers
to the last element, -2 to the second-to-last. Since devices has 5 elements, devices[-
1] returns "printer01"-2.
2. What does the slice operation my_list[1:4] return?
A. Elements at indices 1, 2, 3, and 4
B. Elements at indices 1, 2, and 3 (4 is exclusive)
,C. Elements at indices 1 and 4 only
D. Elements from index 1 to the end of the list
Answer: B
Rationale: In Python slicing, the stop index is exclusive. So [1:4] includes elements at indices
1, 2, and 3. This off-by-one behavior is a common source of errors in automation scripts-2.
3. What does text[::-1] do when text = "Python"?
A. Returns "Python" unchanged
B. Returns "nohtyP" (reverses the string)
C. Returns an error
D. Returns every other character
Answer: B
Rationale: The slice [::-1] uses a negative step value, which reverses the sequence. This is a
concise Python idiom for reversing strings or lists-2.
4. How can you check if a specific value exists in a list?
A. Using the exists() method
B. Using the in keyword
C. Using the find() method
D. Using the contains() method
Answer: B
Rationale: The in keyword checks membership in sequences: if "router01" in
devices: returns True or False. Lists do not have exists() or contains() methods-2.
,5. Which data structure stores network device inventory where each device has a name, IP
address, and role?
A. A single list of all attributes
B. A list of dictionaries, where each dictionary represents a device
C. A tuple containing all devices
D. A string with comma-separated values
Answer: B
Rationale: Dictionaries allow each device to be represented with named keys
(e.g., "name", "ip", "role"), making the data self-documenting and easily accessible. This is
the standard pattern for device inventory management-2.
6. What Python data structure would you use to store unique device IP addresses without
duplicates?
A. List
B. Tuple
C. Set
D. Dictionary
Answer: C
Rationale: Sets automatically eliminate duplicate entries, making them ideal for storing
unique IP addresses. Sets also provide efficient membership testing-2-3.
7. Which approach correctly reads an integer from user input?
A. input('Enter a number:') which automatically returns an integer
B. str(input('Enter a number:')) and relying on implicit conversion
, C. int(input('Enter a number:')) to read and convert in one step
D. float(input('Enter a number:')) and truncating the decimal
Answer: C
Rationale: input() always returns a string in Python 3. int() must wrap it to convert to an
integer-2.
8. What does print() do in Python?
A. Reads user input from the console
B. Outputs text or variables to the console
C. Returns the type of an object
D. Converts a value to a string
Answer: B
Rationale: print() is the built-in function for outputting text or variables to the console-2.
9. Which code adjustment resolves a syntax error caused by missing indentation in an
if/else statement?
A. Add parentheses around the condition
B. Decrease the indentation of the else statement to match the if
C. Add a semicolon at the end of each line
D. Remove the colon after the if and else lines
Answer: B
Rationale: Python requires consistent indentation for code blocks. Misaligned else relative
to if causes an IndentationError-2.
10. What is the output of print(3 * "Hi") in Python?
— Full Practice Exam with correct answers and
rationales updated 2026
Section 1: Python Fundamentals for IT Automation (Questions 1–30)
1. What is the output of the following code?
python
Copy
Download
devices = ["router01", "switch01", "modem01", "gateway01", "printer01"]
print(devices[-1])
A. router01
B. printer01
C. gateway01
D. IndexError
Answer: B
Rationale: Negative indexing in Python allows access from the end of a sequence. -1 refers
to the last element, -2 to the second-to-last. Since devices has 5 elements, devices[-
1] returns "printer01"-2.
2. What does the slice operation my_list[1:4] return?
A. Elements at indices 1, 2, 3, and 4
B. Elements at indices 1, 2, and 3 (4 is exclusive)
,C. Elements at indices 1 and 4 only
D. Elements from index 1 to the end of the list
Answer: B
Rationale: In Python slicing, the stop index is exclusive. So [1:4] includes elements at indices
1, 2, and 3. This off-by-one behavior is a common source of errors in automation scripts-2.
3. What does text[::-1] do when text = "Python"?
A. Returns "Python" unchanged
B. Returns "nohtyP" (reverses the string)
C. Returns an error
D. Returns every other character
Answer: B
Rationale: The slice [::-1] uses a negative step value, which reverses the sequence. This is a
concise Python idiom for reversing strings or lists-2.
4. How can you check if a specific value exists in a list?
A. Using the exists() method
B. Using the in keyword
C. Using the find() method
D. Using the contains() method
Answer: B
Rationale: The in keyword checks membership in sequences: if "router01" in
devices: returns True or False. Lists do not have exists() or contains() methods-2.
,5. Which data structure stores network device inventory where each device has a name, IP
address, and role?
A. A single list of all attributes
B. A list of dictionaries, where each dictionary represents a device
C. A tuple containing all devices
D. A string with comma-separated values
Answer: B
Rationale: Dictionaries allow each device to be represented with named keys
(e.g., "name", "ip", "role"), making the data self-documenting and easily accessible. This is
the standard pattern for device inventory management-2.
6. What Python data structure would you use to store unique device IP addresses without
duplicates?
A. List
B. Tuple
C. Set
D. Dictionary
Answer: C
Rationale: Sets automatically eliminate duplicate entries, making them ideal for storing
unique IP addresses. Sets also provide efficient membership testing-2-3.
7. Which approach correctly reads an integer from user input?
A. input('Enter a number:') which automatically returns an integer
B. str(input('Enter a number:')) and relying on implicit conversion
, C. int(input('Enter a number:')) to read and convert in one step
D. float(input('Enter a number:')) and truncating the decimal
Answer: C
Rationale: input() always returns a string in Python 3. int() must wrap it to convert to an
integer-2.
8. What does print() do in Python?
A. Reads user input from the console
B. Outputs text or variables to the console
C. Returns the type of an object
D. Converts a value to a string
Answer: B
Rationale: print() is the built-in function for outputting text or variables to the console-2.
9. Which code adjustment resolves a syntax error caused by missing indentation in an
if/else statement?
A. Add parentheses around the condition
B. Decrease the indentation of the else statement to match the if
C. Add a semicolon at the end of each line
D. Remove the colon after the if and else lines
Answer: B
Rationale: Python requires consistent indentation for code blocks. Misaligned else relative
to if causes an IndentationError-2.
10. What is the output of print(3 * "Hi") in Python?