WGU D522 Python for IT Automation – 50 Scenario-
Based Questions with Answers & Rationales
Below are 50 original scenario-based practice questions covering Python
fundamentals, file handling, data parsing, automation, and troubleshooting for the WGU
D522 Objective Assessment.
SECTION 1: PYTHON FUNDAMENTALS & SYNTAX
(Questions 1–12)
Question 1
Scenario: A developer is writing an automation script that needs to store a
configuration value for the maximum number of retry attempts. The value should never
change during script execution. Which naming convention should the developer use?
• A) maxRetries = 5
• B) max_retries = 5
• C) MAX_RETRIES = 5
• D) MaxRetries = 5
Answer: C
Rationale: Python uses all uppercase letters to signal that a variable is intended as a
constant. This is a naming convention that tells other developers the value should not
be modified. Python does not enforce immutability .
,Question 2
Scenario: An automation script processes a list of server hostnames. The developer
needs to remove duplicate hostnames while preserving the collection for iteration.
Which data type is most appropriate?
• A) List
• B) Tuple
• C) Set
• D) Dictionary
Answer: C
Rationale: Sets automatically eliminate duplicate values, making them ideal for storing
unique collections like hostnames. Lists allow duplicates, and tuples are immutable but
also allow duplicates .
Question 3
Scenario: A developer writes the following code:
python
a = [1, 2, 3]
b = a
b.append(4)
print(a)
What is printed?
• A) [1, 2, 3]
• B) [1, 2, 3, 4]
• C) [4, 1, 2, 3]
• D) [1, 2, 3][4]
, Answer: B
Rationale: Lists are mutable, and b = a creates an alias, not a copy. Modifying b also
modifies a. To create an independent copy, use b = a.copy() .
Question 4
Scenario: A script needs to extract the substring "Automation" from the string "IT
Automation". Which slice correctly extracts this?
• A) name[3:13]
• B) name[3:12]
• C) name[3:13]
• D) name[2:12]
Answer: C
Rationale: Slicing uses [start:stop] where start is inclusive and stop is exclusive. Index 3
is "A" and index 13 is the character after "n", producing "Automation" .
Question 5
Scenario: A developer needs to convert a user-provided string "42" into an integer for
mathematical operations. Which function should be used?
• A) str("42")
• B) int("42")
• C) float("42")
• D) bool("42")
Based Questions with Answers & Rationales
Below are 50 original scenario-based practice questions covering Python
fundamentals, file handling, data parsing, automation, and troubleshooting for the WGU
D522 Objective Assessment.
SECTION 1: PYTHON FUNDAMENTALS & SYNTAX
(Questions 1–12)
Question 1
Scenario: A developer is writing an automation script that needs to store a
configuration value for the maximum number of retry attempts. The value should never
change during script execution. Which naming convention should the developer use?
• A) maxRetries = 5
• B) max_retries = 5
• C) MAX_RETRIES = 5
• D) MaxRetries = 5
Answer: C
Rationale: Python uses all uppercase letters to signal that a variable is intended as a
constant. This is a naming convention that tells other developers the value should not
be modified. Python does not enforce immutability .
,Question 2
Scenario: An automation script processes a list of server hostnames. The developer
needs to remove duplicate hostnames while preserving the collection for iteration.
Which data type is most appropriate?
• A) List
• B) Tuple
• C) Set
• D) Dictionary
Answer: C
Rationale: Sets automatically eliminate duplicate values, making them ideal for storing
unique collections like hostnames. Lists allow duplicates, and tuples are immutable but
also allow duplicates .
Question 3
Scenario: A developer writes the following code:
python
a = [1, 2, 3]
b = a
b.append(4)
print(a)
What is printed?
• A) [1, 2, 3]
• B) [1, 2, 3, 4]
• C) [4, 1, 2, 3]
• D) [1, 2, 3][4]
, Answer: B
Rationale: Lists are mutable, and b = a creates an alias, not a copy. Modifying b also
modifies a. To create an independent copy, use b = a.copy() .
Question 4
Scenario: A script needs to extract the substring "Automation" from the string "IT
Automation". Which slice correctly extracts this?
• A) name[3:13]
• B) name[3:12]
• C) name[3:13]
• D) name[2:12]
Answer: C
Rationale: Slicing uses [start:stop] where start is inclusive and stop is exclusive. Index 3
is "A" and index 13 is the character after "n", producing "Automation" .
Question 5
Scenario: A developer needs to convert a user-provided string "42" into an integer for
mathematical operations. Which function should be used?
• A) str("42")
• B) int("42")
• C) float("42")
• D) bool("42")