WGU D522: Python for IT Automation OA Practice Exam|
Complete Exam Questions with Verified Correct Answers and
Detailed Explanations – Latest Update 2026/2027 | Graded A+
1. Which statement best describes Python variables?
A. Variables must be declared with a data type before use
B. Variables are created when a value is assigned to them
C. Variables can only store strings
D. Variables cannot change values
✅ Correct Answer: B — Variables are created when a value is assigned
to them
Explanation:
Python uses dynamic typing. A variable does not require a prior declaration;
assigning a value automatically creates the variable and determines its type.
2. Which symbol is used for comments in Python?
A. //
B.
C. #
D. **
✅ Correct Answer: C — #
Explanation:
Python uses the hash symbol (#) to create single-line comments. Comments
are ignored during program execution.
3. What is the output of the following code?
x=5
y=2
,print(x + y)
A. 52
B. 7
C. 3
D. Error
✅ Correct Answer: B — 7
Explanation:
The plus operator performs mathematical addition when used with integers.
4. Which Python data type stores multiple ordered values and can be
modified?
A. Tuple
B. String
C. List
D. Set
✅ Correct Answer: C — List
Explanation:
Lists are ordered collections that are mutable, meaning items can be added,
removed, or changed.
5. Which data structure cannot be modified after creation?
A. List
B. Dictionary
C. Tuple
D. Set
✅ Correct Answer: C — Tuple
,Explanation:
Tuples are immutable collections. Once created, their values cannot be
changed.
6. What does the following code produce?
numbers = [10,20,30]
print(numbers[1])
A. 10
B. 20
C. 30
D. Error
✅ Correct Answer: B — 20
Explanation:
Python indexing starts at 0. Index 1 refers to the second element.
7. Which statement is used to make decisions in Python?
A. switch
B. if
C. choose
D. decision
✅ Correct Answer: B — if
Explanation:
The if statement allows a program to execute code based on whether a
condition is true.
8. What is the purpose of an elif statement?
A. Creates a loop
B. Adds another conditional branch
, C. Defines a function
D. Imports a module
✅ Correct Answer: B — Adds another conditional branch
Explanation:
elif means "else if" and allows multiple conditions to be evaluated.
9. Which loop is commonly used to iterate through a list?
A. repeat loop
B. foreach loop
C. for loop
D. iterate loop
✅ Correct Answer: C — for loop
Explanation:
Python's for loop is designed to iterate through sequences such as lists,
strings, and tuples.
10. What does the range() function generate?
A. Random numbers
B. A sequence of numbers
C. A list of files
D. A dictionary
✅ Correct Answer: B — A sequence of numbers
Explanation:
range() generates a sequence commonly used with loops.
Example:
for i in range(5):
print(i)
Complete Exam Questions with Verified Correct Answers and
Detailed Explanations – Latest Update 2026/2027 | Graded A+
1. Which statement best describes Python variables?
A. Variables must be declared with a data type before use
B. Variables are created when a value is assigned to them
C. Variables can only store strings
D. Variables cannot change values
✅ Correct Answer: B — Variables are created when a value is assigned
to them
Explanation:
Python uses dynamic typing. A variable does not require a prior declaration;
assigning a value automatically creates the variable and determines its type.
2. Which symbol is used for comments in Python?
A. //
B.
C. #
D. **
✅ Correct Answer: C — #
Explanation:
Python uses the hash symbol (#) to create single-line comments. Comments
are ignored during program execution.
3. What is the output of the following code?
x=5
y=2
,print(x + y)
A. 52
B. 7
C. 3
D. Error
✅ Correct Answer: B — 7
Explanation:
The plus operator performs mathematical addition when used with integers.
4. Which Python data type stores multiple ordered values and can be
modified?
A. Tuple
B. String
C. List
D. Set
✅ Correct Answer: C — List
Explanation:
Lists are ordered collections that are mutable, meaning items can be added,
removed, or changed.
5. Which data structure cannot be modified after creation?
A. List
B. Dictionary
C. Tuple
D. Set
✅ Correct Answer: C — Tuple
,Explanation:
Tuples are immutable collections. Once created, their values cannot be
changed.
6. What does the following code produce?
numbers = [10,20,30]
print(numbers[1])
A. 10
B. 20
C. 30
D. Error
✅ Correct Answer: B — 20
Explanation:
Python indexing starts at 0. Index 1 refers to the second element.
7. Which statement is used to make decisions in Python?
A. switch
B. if
C. choose
D. decision
✅ Correct Answer: B — if
Explanation:
The if statement allows a program to execute code based on whether a
condition is true.
8. What is the purpose of an elif statement?
A. Creates a loop
B. Adds another conditional branch
, C. Defines a function
D. Imports a module
✅ Correct Answer: B — Adds another conditional branch
Explanation:
elif means "else if" and allows multiple conditions to be evaluated.
9. Which loop is commonly used to iterate through a list?
A. repeat loop
B. foreach loop
C. for loop
D. iterate loop
✅ Correct Answer: C — for loop
Explanation:
Python's for loop is designed to iterate through sequences such as lists,
strings, and tuples.
10. What does the range() function generate?
A. Random numbers
B. A sequence of numbers
C. A list of files
D. A dictionary
✅ Correct Answer: B — A sequence of numbers
Explanation:
range() generates a sequence commonly used with loops.
Example:
for i in range(5):
print(i)