PYTHON FOR IT AUTOMATION: EXAM
(LATEST 2026/2027 UPDATE), WITH
CORRECT/ACCURATE ANSWERS
WGU D522 OBJECTIVE ASSESSMENT
PYTHON FOR IT AUTOMATION
WGU D522 – Python for IT Automation
Objective Assessment
Question 1
What is the primary advantage of using dictionaries in Python?
A. They store data in a fixed order
B. They allow values to be associated with descriptive keys
C. They only store numeric data
D. They consume less memory than lists
✅ Correct Answer: B
Rationale:
Dictionaries store data as key–value pairs, which allows information to be labeled in a
meaningful and readable way. This makes data retrieval efficient because values are
accessed using descriptive keys rather than numeric indexes. Dictionaries are ideal for
representing relationships such as device names and IP addresses. Their structure
improves code clarity and maintainability in automation tasks.
Question 2
Which Python code snippet correctly demonstrates the creation of a dictionary with
key-value pairs?
,A. devices = ('Router1', '192.168.1.2')
B. devices = ['Router1' = '192.168.1.2']
C. devices = {'Router1': '192.168.1.2', 'Switch2': '10.0.0.2'}
D. devices = {'Router1', 'Switch2'}
✅ Correct Answer: C
Rationale:
A dictionary in Python uses curly braces with keys and values separated by colons.
Option C correctly maps device names to their corresponding IP addresses. This
structure allows efficient lookups and updates. The other options either misuse syntax
or represent different data structures.
Question 3
Which Python code snippet correctly demonstrates the creation of a dictionary using
various data types for both keys and values?
A. data = ['string', (1,2,3)]
B. data = {'string_key': [1,2,3], (4,5,6): 'tuple_key'}
C. data = {'key': 'value', 'key': 'value2'}
D. data = {['list']: 'invalid'}
✅ Correct Answer: B
Rationale:
Python dictionaries allow immutable data types, such as strings and tuples, to be used
as keys. Values can be any data type, including lists. This flexibility makes dictionaries
powerful for storing structured data. Option B correctly demonstrates valid key and
value combinations.
Question 4
,Which Python code snippet correctly demonstrates the use of the dictionary
constructor dict()?
A. d = dict('key1', 'value1')
B. d = dict([('key1','value1'),('key2','value2')])
C. d = dict{'key1':'value1'}
D. d = dict(['key1':'value1'])
✅ Correct Answer: B
Rationale:
The dict() constructor can accept an iterable of key-value tuples. This approach is
useful when dynamically creating dictionaries from data sources. Option B correctly
follows the required structure. The other options contain syntax errors or invalid
formats.
Question 5
How can an item be accessed in a Python dictionary using its key?
A. By using an index number
B. By calling the get() method only
C. By referencing the key inside square brackets
D. By looping through the dictionary
✅ Correct Answer: C
Rationale:
Dictionary values are accessed by placing the key inside square brackets. This
provides direct and fast access to the stored value. While get() is also valid, square
bracket access is the most straightforward method. Indexing does not apply to
dictionaries.
Question 6
, Which Python code snippet correctly demonstrates changing the value of a specific
key in a dictionary?
A. devices.update = "192.168.1.100"
B. devices["DeviceA"] == "192.168.1.100"
C. devices["DeviceA"] = "192.168.1.100"
D. devices.add("DeviceA","192.168.1.100")
✅ Correct Answer: C
Rationale:
Updating a dictionary value is done by assigning a new value to an existing key.
Python automatically overwrites the previous value. This method is commonly used in
automation scripts to update configurations. The other options use incorrect operators
or methods.
Question 7
Which Python method is used to merge key-value pairs from one dictionary into
another?
A. merge()
B. append()
C. update()
D. extend()
✅ Correct Answer: C
Rationale:
The update() method adds new key-value pairs and overwrites existing keys when
conflicts occur. This is useful when consolidating configuration data from multiple
sources. It modifies the original dictionary in place. The other methods do not apply to
dictionaries.