WGU D335 Intro to Python – PACKAGE DEAL –
Complete Solutions for OA and PA –
2025/2026 Edition
Section 1: Python Basics (Q1–Q25)
1. Which of the following is a valid variable name in Python?
A. 2nd_variable
B. my-variable
C. my_variable
D. class
Answer: C
Rationale: Variable names must start with a letter or underscore, cannot contain
hyphens, and cannot be reserved keywords like class. my_variable follows all
rules.
2. What data type is the result of in Python 3?
A. int
B. float
C. str
D. bool
Answer: B
Rationale: The / operator always returns a float in Python 3, even if the result is a
whole number. yields 1.5.
3. What is the output of print(2 ** 3)?
A. 6
B. 8
C. 9
D. 5
Answer: B
Rationale: ** is the exponentiation operator. 2 ** 3 means 2 raised to the power
of 3, which equals 8.
,4. Which of the following is NOT a valid Python data type?
A. list
B. tuple
C. array
D. dictionary
Answer: C
Rationale: array is not a built-in Python data type (though it exists in the array
module). Built-in types include list, tuple, dict, set, etc.
5. What is the result of 10 // 3?
A. 3.33
B. 3
C. 4
D. 3.0
Answer: B
Rationale: // is floor division. It returns the integer quotient, discarding any
remainder. 10 // 3 equals 3.
6. Which operator is used for string concatenation?
A. +
B. *
C. &
D. .
Answer: A
Rationale: The + operator concatenates strings, e.g., "Hello" + "World" yields
"HelloWorld".
7. What is the output of print(type(5))?
A. <class 'int'>
B. <class 'float'>
C. <class 'str'>
D. <class 'bool'>
Answer: A
Rationale: 5 is an integer, so type(5) returns <class 'int'>.
,8. Which of the following is used to take input from the user in Python?
A. input()
B. get()
C. read()
D. scan()
Answer: A
Rationale: The input() function reads a line from the user and returns it as a
string.
9. What is the value of x after x = int("10") + 5?
A. 15
B. "105"
C. 105
D. Error
Answer: A
Rationale: int("10") converts the string to integer 10. 10 + 5 = 15.
10. Which of the following is an immutable data type?
A. list
B. dictionary
C. set
D. tuple
Answer: D
Rationale: Tuples are immutable; once created, their elements cannot be
changed. Lists, dictionaries, and sets are mutable.
11. What does the bool data type represent?
A. Only True
B. Only False
C. True or False
D. 0 or 1
Answer: C
Rationale: The bool type has two values: True and False. It is a subclass of int,
where True=1 and False=0.
, 12. What is the output of print(5 == 5.0)?
A. True
B. False
C. Error
D. None
Answer: A
Rationale: Python considers 5 and 5.0 equal in value, so == returns True.
13. Which of the following converts a string to an integer?
A. str()
B. int()
C. float()
D. chr()
Answer: B
Rationale: int() converts a string or float to an integer, e.g., int("42") returns 42.
14. What is the result of len("Python")?
A. 5
B. 6
C. 7
D. Error
Answer: B
Rationale: len() returns the number of characters in a string. "Python" has 6
characters.
15. Which of the following is used for comments in Python?
A. //
B. /* */
C. #
D. --
Answer: C
Rationale: The # symbol starts a single-line comment in Python.
16. What is the output of print(10 % 3)?
A. 1
Complete Solutions for OA and PA –
2025/2026 Edition
Section 1: Python Basics (Q1–Q25)
1. Which of the following is a valid variable name in Python?
A. 2nd_variable
B. my-variable
C. my_variable
D. class
Answer: C
Rationale: Variable names must start with a letter or underscore, cannot contain
hyphens, and cannot be reserved keywords like class. my_variable follows all
rules.
2. What data type is the result of in Python 3?
A. int
B. float
C. str
D. bool
Answer: B
Rationale: The / operator always returns a float in Python 3, even if the result is a
whole number. yields 1.5.
3. What is the output of print(2 ** 3)?
A. 6
B. 8
C. 9
D. 5
Answer: B
Rationale: ** is the exponentiation operator. 2 ** 3 means 2 raised to the power
of 3, which equals 8.
,4. Which of the following is NOT a valid Python data type?
A. list
B. tuple
C. array
D. dictionary
Answer: C
Rationale: array is not a built-in Python data type (though it exists in the array
module). Built-in types include list, tuple, dict, set, etc.
5. What is the result of 10 // 3?
A. 3.33
B. 3
C. 4
D. 3.0
Answer: B
Rationale: // is floor division. It returns the integer quotient, discarding any
remainder. 10 // 3 equals 3.
6. Which operator is used for string concatenation?
A. +
B. *
C. &
D. .
Answer: A
Rationale: The + operator concatenates strings, e.g., "Hello" + "World" yields
"HelloWorld".
7. What is the output of print(type(5))?
A. <class 'int'>
B. <class 'float'>
C. <class 'str'>
D. <class 'bool'>
Answer: A
Rationale: 5 is an integer, so type(5) returns <class 'int'>.
,8. Which of the following is used to take input from the user in Python?
A. input()
B. get()
C. read()
D. scan()
Answer: A
Rationale: The input() function reads a line from the user and returns it as a
string.
9. What is the value of x after x = int("10") + 5?
A. 15
B. "105"
C. 105
D. Error
Answer: A
Rationale: int("10") converts the string to integer 10. 10 + 5 = 15.
10. Which of the following is an immutable data type?
A. list
B. dictionary
C. set
D. tuple
Answer: D
Rationale: Tuples are immutable; once created, their elements cannot be
changed. Lists, dictionaries, and sets are mutable.
11. What does the bool data type represent?
A. Only True
B. Only False
C. True or False
D. 0 or 1
Answer: C
Rationale: The bool type has two values: True and False. It is a subclass of int,
where True=1 and False=0.
, 12. What is the output of print(5 == 5.0)?
A. True
B. False
C. Error
D. None
Answer: A
Rationale: Python considers 5 and 5.0 equal in value, so == returns True.
13. Which of the following converts a string to an integer?
A. str()
B. int()
C. float()
D. chr()
Answer: B
Rationale: int() converts a string or float to an integer, e.g., int("42") returns 42.
14. What is the result of len("Python")?
A. 5
B. 6
C. 7
D. Error
Answer: B
Rationale: len() returns the number of characters in a string. "Python" has 6
characters.
15. Which of the following is used for comments in Python?
A. //
B. /* */
C. #
D. --
Answer: C
Rationale: The # symbol starts a single-line comment in Python.
16. What is the output of print(10 % 3)?
A. 1