WGU E010 FOUNDATIONS OF PROGRAMMING (PYTHON) PRACTICE ASSESSMENT| ALL
QUESTIONS AND CORRECT ANSWERS | VERIFIED ANSWERS | UPDATED VERSION!
Question 1
Which symbol is used to begin a single-line comment in Python?
A) //
B) /*
C) #
D) %
E) --
Correct Answer: C) #
Rationale: In Python, the pound symbol (#) is used to indicate that the rest of the line is a
comment and should be ignored by the interpreter. The double forward slash (//) is used for
comments in languages like Java or C++, but in Python, it is the floor division operator.
Question 2
Which data type is the value 3.14 categorized as in Python?
A) Integer
B) Boolean
C) String
D) Float
E) Complex
Correct Answer: D) Float
Rationale: Numerical values that contain a decimal point are represented as the "float"
(floating-point) data type. Integers are whole numbers without decimals, and strings
represent text.
Question 3
In a Python for loop, what must immediately follow the in keyword?
A) A boolean condition
B) An iterable object
C) A function definition
D) A mathematical operator
E) A string literal only
Correct Answer: B) An iterable object
Rationale: The syntax for item in iterable: requires an object that can return its members
one at a time, such as a list, tuple, string, dictionary, or range object.
Question 4
Which type of loop is specifically designed for iterating a specific, predetermined number of
times?
A) while loop
B) for loop
C) do-while loop
, 2
D) infinite loop
E) nested while loop
Correct Answer: B) for loop
Rationale: A for loop in Python is used to iterate over a sequence (iterable). Because the size
of the sequence is usually known or defined by a range(), it is the preferred choice for fixed
iterations.
Question 5
Which components are syntactically required in every Python while loop?
A) A counter variable and a break statement
B) A list and an iterator
C) A condition and an indented code block
D) A for keyword and a range function
E) A return statement and a dictionary
Correct Answer: C) A condition and an indented code block
Rationale: A while loop continues to execute as long as its condition evaluates to True.
Python uses indentation to define the block of code that belongs to the loop.
Question 6
Which keyword is used to exit a loop immediately, regardless of whether the loop condition is
still met?
A) stop
B) end
C) exit
D) return
E) break
Correct Answer: E) break
Rationale: The break statement provides a way to terminate the current loop prematurely.
Once a break is encountered, program execution resumes at the next statement following
the loop block.
Question 7
In the code for item in my_list:, what does the variable item represent?
A) The index position of the current element
B) The total length of the list
C) The current element being processed in the iteration
D) A copy of the entire list
E) The last element in the list
Correct Answer: C) The current element being processed in the iteration
Rationale: In a for loop, the variable defined before the in keyword acts as a placeholder
, 3
that automatically takes on the value of each element in the sequence, one by one, as the
loop progresses.
Question 8
Which Python data structure is unordered and automatically prevents duplicate values from
being stored?
A) List
B) Tuple
C) Dictionary
D) Set
E) String
Correct Answer: D) Set
Rationale: A set is a collection of unique elements. If you attempt to add an item that
already exists in the set, Python will simply ignore the addition, ensuring no duplicates are
present.
Question 9
Which Python data structure is "immutable," meaning it cannot be modified after it is created?
A) List
B) Set
C) Tuple
D) Dictionary
E) Array
Correct Answer: C) Tuple
Rationale: Tuples are defined using parentheses () and are immutable. Once a tuple is
defined, you cannot add, remove, or change its elements, making them useful for fixed data
collections.
Question 10
What must a developer do to run Python code that has been written in a standard text editor?
A) Convert the code to machine language manually.
B) Save the file and use a Python interpreter to execute it.
C) Upload the code to a specific web server first.
D) Rename the file to an .exe extension.
E) Only text editors with "Run" buttons can execute Python.
Correct Answer: B) Save the file and use a Python interpreter to execute it.
Rationale: Python is an interpreted language. The source code must be saved (typically with
a .py extension) and then processed by the Python interpreter software to run the
instructions.
QUESTIONS AND CORRECT ANSWERS | VERIFIED ANSWERS | UPDATED VERSION!
Question 1
Which symbol is used to begin a single-line comment in Python?
A) //
B) /*
C) #
D) %
E) --
Correct Answer: C) #
Rationale: In Python, the pound symbol (#) is used to indicate that the rest of the line is a
comment and should be ignored by the interpreter. The double forward slash (//) is used for
comments in languages like Java or C++, but in Python, it is the floor division operator.
Question 2
Which data type is the value 3.14 categorized as in Python?
A) Integer
B) Boolean
C) String
D) Float
E) Complex
Correct Answer: D) Float
Rationale: Numerical values that contain a decimal point are represented as the "float"
(floating-point) data type. Integers are whole numbers without decimals, and strings
represent text.
Question 3
In a Python for loop, what must immediately follow the in keyword?
A) A boolean condition
B) An iterable object
C) A function definition
D) A mathematical operator
E) A string literal only
Correct Answer: B) An iterable object
Rationale: The syntax for item in iterable: requires an object that can return its members
one at a time, such as a list, tuple, string, dictionary, or range object.
Question 4
Which type of loop is specifically designed for iterating a specific, predetermined number of
times?
A) while loop
B) for loop
C) do-while loop
, 2
D) infinite loop
E) nested while loop
Correct Answer: B) for loop
Rationale: A for loop in Python is used to iterate over a sequence (iterable). Because the size
of the sequence is usually known or defined by a range(), it is the preferred choice for fixed
iterations.
Question 5
Which components are syntactically required in every Python while loop?
A) A counter variable and a break statement
B) A list and an iterator
C) A condition and an indented code block
D) A for keyword and a range function
E) A return statement and a dictionary
Correct Answer: C) A condition and an indented code block
Rationale: A while loop continues to execute as long as its condition evaluates to True.
Python uses indentation to define the block of code that belongs to the loop.
Question 6
Which keyword is used to exit a loop immediately, regardless of whether the loop condition is
still met?
A) stop
B) end
C) exit
D) return
E) break
Correct Answer: E) break
Rationale: The break statement provides a way to terminate the current loop prematurely.
Once a break is encountered, program execution resumes at the next statement following
the loop block.
Question 7
In the code for item in my_list:, what does the variable item represent?
A) The index position of the current element
B) The total length of the list
C) The current element being processed in the iteration
D) A copy of the entire list
E) The last element in the list
Correct Answer: C) The current element being processed in the iteration
Rationale: In a for loop, the variable defined before the in keyword acts as a placeholder
, 3
that automatically takes on the value of each element in the sequence, one by one, as the
loop progresses.
Question 8
Which Python data structure is unordered and automatically prevents duplicate values from
being stored?
A) List
B) Tuple
C) Dictionary
D) Set
E) String
Correct Answer: D) Set
Rationale: A set is a collection of unique elements. If you attempt to add an item that
already exists in the set, Python will simply ignore the addition, ensuring no duplicates are
present.
Question 9
Which Python data structure is "immutable," meaning it cannot be modified after it is created?
A) List
B) Set
C) Tuple
D) Dictionary
E) Array
Correct Answer: C) Tuple
Rationale: Tuples are defined using parentheses () and are immutable. Once a tuple is
defined, you cannot add, remove, or change its elements, making them useful for fixed data
collections.
Question 10
What must a developer do to run Python code that has been written in a standard text editor?
A) Convert the code to machine language manually.
B) Save the file and use a Python interpreter to execute it.
C) Upload the code to a specific web server first.
D) Rename the file to an .exe extension.
E) Only text editors with "Run" buttons can execute Python.
Correct Answer: B) Save the file and use a Python interpreter to execute it.
Rationale: Python is an interpreted language. The source code must be saved (typically with
a .py extension) and then processed by the Python interpreter software to run the
instructions.