Assessment 2026/2027 | 15 Actual
Questions and Answers | 100% Correct
WGU D335 Intro to Python – Practice
Questions (15 Questions)
1. What is the correct way to declare a variable x with the value 10 in
Python?
A. int x = 10
B. x = 10
C. x := 10
D. var x = 10
✅ Answer: B
Explanation: Python uses dynamic typing; variables are assigned with = without specifying a
type.
2. Which Python data type is immutable?
A. List
B. Dictionary
C. Tuple
✅
D. Set
Answer: C
Explanation: Tuples cannot be changed after creation; lists and dictionaries are mutable.
,3. What is the output of the following code?
print(2 ** 3)
A. 6
B. 8
C. 9
D. 5
✅ Answer: B
Explanation: ** is the exponent operator; 2³ = 8.
4. How do you start a comment in Python?
A. // This is a comment
B. /* This is a comment */
C. # This is a comment
D. <!-- This is a comment -->
✅ Answer: C
Explanation: Python comments start with #.
5. Which of the following is a valid Python function definition?
A. function my_func():
B. def my_func():
C. func my_func():
D. define my_func():
✅ Answer: B
Explanation: Functions are defined in Python with def.
6. What is the output of the following code?
my_list = [1, 2, 3]
print(my_list[1])
A. 1
B. 2
, C. 3
D. Error
✅ Answer: B
Explanation: Lists are zero-indexed; index 1 corresponds to the second element.
7. Which operator is used for floor division in Python?
A. /
B. //
C. %
D. **
✅ Answer: B
Explanation: // divides and returns the integer part of the quotient.
8. Which of the following will create a set in Python?
A. my_set = {1, 2, 3}
B. my_set = [1, 2, 3]
C. my_set = (1, 2, 3)
D. my_set = {}
✅ Answer: A
Explanation: Curly braces with elements create a set. {} alone creates an empty dictionary.
9. What is the output of this code?
x = "Python"
print(x[0:4])
A. Pyth
B. Pytho
C. Python
D. Py
✅ Answer: A
Explanation: Slicing [0:4] extracts characters from index 0 up to but not including index 4.