WGU E010 OBJECTIVE
ASSESSMENT FINAL AND
PRACTICE QUESTIONS AND
SOLUTIONS
SECTION 1: BASIC SYNTAX & DATA TYPES (Questions 1–20)
Q1. What is the output of print(type(10/2))?
A) <class 'int'>
B) <class 'float'>
C) <class 'double'>
D) <class 'str'>
Answer: B. <class 'float'>
Rationale: In Python, the / operator performs true division and always returns a float, even when the
numbers divide evenly (e.g., 10/2 = 5.0). This differs from many other languages that would return an
integer. To get integer division, use // (floor division).
Q2. Which of the following data types is immutable?
A) list
B) dict
C) set
D) tuple
Answer: D. tuple
Rationale: A tuple cannot be changed after creation (immutable). Lists, dictionaries, and sets
are mutable and can be modified after creation (adding, removing, or changing elements). This
immutability makes tuples hashable and usable as dictionary keys.
Q3. What will the following code print?
python
,x = "Hello"
print(x[1])
A) H
B) e
C) l
D) o
Answer: B. e
Rationale: Strings in Python are zero-indexed, meaning the first character has index 0. Index mapping:
H(0), e(1), l(2), l(3), o(4). So x[1] returns the second character, which is "e".
Q4. What is the output of print(2 ** 3)?
A) 6
B) 8
C) 9
D) 5
Answer: B. 8
Rationale: The ** operator is the exponentiation operator. 2 ** 3 means 2 raised to the power of 3,
which is 2 × 2 × 2 = 8. Note that ^ is the bitwise XOR operator in Python, not exponentiation.
Q5. Which loop is best used when the number of iterations is unknown?
A) for loop
B) while loop
C) nested loop
D) for-each loop
Answer: B. while loop
Rationale: A while loop runs until a condition becomes False, making it ideal when the number of
iterations is not known in advance (e.g., user input validation, reading until end of file). for loops are
designed for iterating a known number of times or over a fixed sequence.
Q6. What does the break statement do in a loop?
A) Skips the current iteration
B) Exits the loop completely
C) Restarts the loop from the beginning
D) Pauses the loop temporarily
,Answer: B. Exits the loop completely
Rationale: The break statement immediately terminates the nearest enclosing loop (for or while).
Execution continues with the first statement after the loop. continue skips only the current
iteration; pass does nothing.
Q7. What is the output of print("Python"[::-1])?
A) "Python"
B) "nohtyP"
C) "Pytho"
D) "n"
Answer: B. "nohtyP"
Rationale: This is a string slice with a step of -1, which reverses the string. The syntax [::-1] means: start
from the end, go to the beginning, stepping backwards by one character. It's a common Python idiom
for string reversal.
Q8. Which data type is the value 3.14 in Python?
A) Integer
B) Float
C) String
D) Boolean
Answer: B. Float
Rationale: Numbers with a decimal point are of type float (floating-point number) in Python, regardless
of whether the fractional part is zero. Integers have no decimal point. Use type(3.14) to verify.
Q9. What is the value of 10 % 3?
A) 1
B) 2
C) 3
D) 0
Answer: A. 1
Rationale: The % operator is the modulo (remainder) operator. It returns the remainder of division: 10
divided by 3 equals 3 with a remainder of 1. This is useful for checking even/odd numbers (num % 2 ==
0), cycling through ranges, and many other applications.
, Q10. Which of the following is a valid Python variable name?
A) 2variable
B) variable-2
C) _myVariable
D) my variable
Answer: C. _myVariable
Rationale: Variable naming rules in Python:
Must start with a letter (a-z, A-Z) or underscore (_)
Cannot start with a digit
Can contain letters, digits, and underscores only
Cannot contain spaces or hyphens
Case-sensitive
Underscore is allowed and commonly used for "private" variables or placeholder values.
Q11. What does the append() method do when called on a list?
A) Removes an element from the list
B) Adds an element to the end of the list
C) Inserts an element at a specific index
D) Sorts the list
Answer: B. Adds an element to the end of the list
Rationale: append() adds a single element to the end of a list, increasing the list's length by one. For
adding multiple elements, use extend(). To insert at a specific position, use insert().
Q12. What is the output of bool([])?
A) True
B) False
C) None
D) Error
Answer: B. False
Rationale: In Python, empty containers (lists [], dictionaries {}, sets set(), tuples (), strings "") evaluate
to False in a boolean context. Non-empty containers evaluate to True. This is useful for checking if a list
has elements without explicitly calling len().
ASSESSMENT FINAL AND
PRACTICE QUESTIONS AND
SOLUTIONS
SECTION 1: BASIC SYNTAX & DATA TYPES (Questions 1–20)
Q1. What is the output of print(type(10/2))?
A) <class 'int'>
B) <class 'float'>
C) <class 'double'>
D) <class 'str'>
Answer: B. <class 'float'>
Rationale: In Python, the / operator performs true division and always returns a float, even when the
numbers divide evenly (e.g., 10/2 = 5.0). This differs from many other languages that would return an
integer. To get integer division, use // (floor division).
Q2. Which of the following data types is immutable?
A) list
B) dict
C) set
D) tuple
Answer: D. tuple
Rationale: A tuple cannot be changed after creation (immutable). Lists, dictionaries, and sets
are mutable and can be modified after creation (adding, removing, or changing elements). This
immutability makes tuples hashable and usable as dictionary keys.
Q3. What will the following code print?
python
,x = "Hello"
print(x[1])
A) H
B) e
C) l
D) o
Answer: B. e
Rationale: Strings in Python are zero-indexed, meaning the first character has index 0. Index mapping:
H(0), e(1), l(2), l(3), o(4). So x[1] returns the second character, which is "e".
Q4. What is the output of print(2 ** 3)?
A) 6
B) 8
C) 9
D) 5
Answer: B. 8
Rationale: The ** operator is the exponentiation operator. 2 ** 3 means 2 raised to the power of 3,
which is 2 × 2 × 2 = 8. Note that ^ is the bitwise XOR operator in Python, not exponentiation.
Q5. Which loop is best used when the number of iterations is unknown?
A) for loop
B) while loop
C) nested loop
D) for-each loop
Answer: B. while loop
Rationale: A while loop runs until a condition becomes False, making it ideal when the number of
iterations is not known in advance (e.g., user input validation, reading until end of file). for loops are
designed for iterating a known number of times or over a fixed sequence.
Q6. What does the break statement do in a loop?
A) Skips the current iteration
B) Exits the loop completely
C) Restarts the loop from the beginning
D) Pauses the loop temporarily
,Answer: B. Exits the loop completely
Rationale: The break statement immediately terminates the nearest enclosing loop (for or while).
Execution continues with the first statement after the loop. continue skips only the current
iteration; pass does nothing.
Q7. What is the output of print("Python"[::-1])?
A) "Python"
B) "nohtyP"
C) "Pytho"
D) "n"
Answer: B. "nohtyP"
Rationale: This is a string slice with a step of -1, which reverses the string. The syntax [::-1] means: start
from the end, go to the beginning, stepping backwards by one character. It's a common Python idiom
for string reversal.
Q8. Which data type is the value 3.14 in Python?
A) Integer
B) Float
C) String
D) Boolean
Answer: B. Float
Rationale: Numbers with a decimal point are of type float (floating-point number) in Python, regardless
of whether the fractional part is zero. Integers have no decimal point. Use type(3.14) to verify.
Q9. What is the value of 10 % 3?
A) 1
B) 2
C) 3
D) 0
Answer: A. 1
Rationale: The % operator is the modulo (remainder) operator. It returns the remainder of division: 10
divided by 3 equals 3 with a remainder of 1. This is useful for checking even/odd numbers (num % 2 ==
0), cycling through ranges, and many other applications.
, Q10. Which of the following is a valid Python variable name?
A) 2variable
B) variable-2
C) _myVariable
D) my variable
Answer: C. _myVariable
Rationale: Variable naming rules in Python:
Must start with a letter (a-z, A-Z) or underscore (_)
Cannot start with a digit
Can contain letters, digits, and underscores only
Cannot contain spaces or hyphens
Case-sensitive
Underscore is allowed and commonly used for "private" variables or placeholder values.
Q11. What does the append() method do when called on a list?
A) Removes an element from the list
B) Adds an element to the end of the list
C) Inserts an element at a specific index
D) Sorts the list
Answer: B. Adds an element to the end of the list
Rationale: append() adds a single element to the end of a list, increasing the list's length by one. For
adding multiple elements, use extend(). To insert at a specific position, use insert().
Q12. What is the output of bool([])?
A) True
B) False
C) None
D) Error
Answer: B. False
Rationale: In Python, empty containers (lists [], dictionaries {}, sets set(), tuples (), strings "") evaluate
to False in a boolean context. Non-empty containers evaluate to True. This is useful for checking if a list
has elements without explicitly calling len().