,WGU D522 Python for IT Automation – Complete OA Prep Bundle (Timed
Mock Exam + Practice Questions + Full Answers) | 2026 Pass Guarantee.
1. What is the correct way to assign the integer 10 to a variable named count in
Python?
Answer: count = 10
Explanation: Python uses the assignment operator = to store a value in a variable.
2. Which data type would you use to store a sequence of characters such as
"server01"?
Answer: str
Explanation: Text values are stored as strings in Python.
3. What will this code print?
x = 5
y = 2
print(x // y)
Answer: 2
Explanation: // performs floor division, so 5 // 2 returns 2.
4. What is the purpose of indentation in Python?
Answer: It defines code blocks.
Explanation: Python uses indentation to determine which statements belong inside loops,
functions, conditionals, and other structures.
5. Which statement is used to add a comment in Python?
Answer: A line beginning with #
Explanation: Anything after # on a line is treated as a comment.
6. What is the output of:
print(type(3.14))
Answer: <class 'float'>
Explanation: 3.14 is a floating-point number.
7. Which operator is used for exponentiation in Python?
,Answer: **
Explanation: For example, 2 ** 3 evaluates to 8.
8. What does the following expression return?
10 % 3
Answer: 1
Explanation: % returns the remainder after division.
9. What is the result of:
"Py" + "thon"
Answer: "Python"
Explanation: The + operator concatenates strings.
10. Which built-in function returns the number of items in a list?
Answer: len()
Explanation: len([1,2,3]) returns 3.
11. What is a list in Python?
Answer: A mutable ordered collection of items.
Explanation: Lists can store multiple values and can be changed after creation.
12. How do you access the first element of a list named items?
Answer: items[0]
Explanation: Python uses zero-based indexing.
13. Which method adds an item to the end of a list?
Answer: .append()
Explanation: Example: items.append("router")
14. What is the difference between a list and a tuple?
Answer: A list is mutable; a tuple is immutable.
Explanation: Lists can be modified, while tuples cannot after creation.
15. Which data structure stores key-value pairs?
, Answer: Dictionary
Explanation: Dictionaries map keys to values, such as {"host": "server1"}.
16. How do you retrieve the value for key "ip" from dictionary device?
Answer: device["ip"]
Explanation: Square brackets with the key return the associated value.
17. What does device.get("ip") do?
Answer: It returns the value for "ip" if it exists, or None if it does not.
Explanation: .get() avoids a KeyError when the key is missing.
18. What kind of collection is a set?
Answer: An unordered collection of unique items.
Explanation: Sets automatically remove duplicates.
19. What is the result of:
set([1, 1, 2, 3])
Answer: {1, 2, 3}
Explanation: Duplicate values are removed in a set.
20. When would a dictionary be preferred over a list?
Answer: When you need to look up values by meaningful keys instead of numeric positions.
Explanation: Dictionaries are ideal for storing structured data like usernames, IPs, or
configurations.
21. Which keyword starts a conditional statement in Python?
Answer: if
Explanation: if checks whether a condition is true.
22. What keyword provides an alternative condition after if?
Answer: elif
Explanation: elif allows multiple conditions to be tested.
23. What keyword runs code when all previous conditions are false?
Mock Exam + Practice Questions + Full Answers) | 2026 Pass Guarantee.
1. What is the correct way to assign the integer 10 to a variable named count in
Python?
Answer: count = 10
Explanation: Python uses the assignment operator = to store a value in a variable.
2. Which data type would you use to store a sequence of characters such as
"server01"?
Answer: str
Explanation: Text values are stored as strings in Python.
3. What will this code print?
x = 5
y = 2
print(x // y)
Answer: 2
Explanation: // performs floor division, so 5 // 2 returns 2.
4. What is the purpose of indentation in Python?
Answer: It defines code blocks.
Explanation: Python uses indentation to determine which statements belong inside loops,
functions, conditionals, and other structures.
5. Which statement is used to add a comment in Python?
Answer: A line beginning with #
Explanation: Anything after # on a line is treated as a comment.
6. What is the output of:
print(type(3.14))
Answer: <class 'float'>
Explanation: 3.14 is a floating-point number.
7. Which operator is used for exponentiation in Python?
,Answer: **
Explanation: For example, 2 ** 3 evaluates to 8.
8. What does the following expression return?
10 % 3
Answer: 1
Explanation: % returns the remainder after division.
9. What is the result of:
"Py" + "thon"
Answer: "Python"
Explanation: The + operator concatenates strings.
10. Which built-in function returns the number of items in a list?
Answer: len()
Explanation: len([1,2,3]) returns 3.
11. What is a list in Python?
Answer: A mutable ordered collection of items.
Explanation: Lists can store multiple values and can be changed after creation.
12. How do you access the first element of a list named items?
Answer: items[0]
Explanation: Python uses zero-based indexing.
13. Which method adds an item to the end of a list?
Answer: .append()
Explanation: Example: items.append("router")
14. What is the difference between a list and a tuple?
Answer: A list is mutable; a tuple is immutable.
Explanation: Lists can be modified, while tuples cannot after creation.
15. Which data structure stores key-value pairs?
, Answer: Dictionary
Explanation: Dictionaries map keys to values, such as {"host": "server1"}.
16. How do you retrieve the value for key "ip" from dictionary device?
Answer: device["ip"]
Explanation: Square brackets with the key return the associated value.
17. What does device.get("ip") do?
Answer: It returns the value for "ip" if it exists, or None if it does not.
Explanation: .get() avoids a KeyError when the key is missing.
18. What kind of collection is a set?
Answer: An unordered collection of unique items.
Explanation: Sets automatically remove duplicates.
19. What is the result of:
set([1, 1, 2, 3])
Answer: {1, 2, 3}
Explanation: Duplicate values are removed in a set.
20. When would a dictionary be preferred over a list?
Answer: When you need to look up values by meaningful keys instead of numeric positions.
Explanation: Dictionaries are ideal for storing structured data like usernames, IPs, or
configurations.
21. Which keyword starts a conditional statement in Python?
Answer: if
Explanation: if checks whether a condition is true.
22. What keyword provides an alternative condition after if?
Answer: elif
Explanation: elif allows multiple conditions to be tested.
23. What keyword runs code when all previous conditions are false?