WGU D335 Introduction to Programming in Python
OBJECTIVE ASSESSMENT ACTUAL EXAM 2025/2026
QUESTIONS WITH VERIFIED CORRECT SOLUTIONS ||
100% GUARANTEED PASS <BRAND NEW VERSION>
WGU D335 Python Practice Exam
1. What is the output of the following code?
python
x=5
y=2
result = x // y
print(result)
A) 2.5
B) 2 ✓
C) 3
D) 2.0
2. Which data type is mutable in Python?
A) int
B) str
C) tuple
D) list ✓
3. What keyword is used to define a function in Python?
A) func
B) define
C) def ✓
D) function
4. What will print(type(10.0)) output?
A) <class 'int'>
B) <class 'float'> ✓
C) <class 'double'>
D) <class 'number'>
,5. Which of the following is a valid variable name?
A) 2nd_var
B) my-variable
C) _my_var ✓
D) global
6. What does the append() method do?
A) Adds an element to the beginning of a list.
B) Adds an element to the end of a list. ✓
C) Removes the last element of a list.
D) Sorts the list in ascending order.
7. How do you start a single-line comment in Python?
A) //
B) /*
C) # ✓
D) --
8. What is the result of "hello" + "world"?
A) hello world
B) helloworld ✓
C) "hello"+"world"
D) An error
9. Which operator is used for exponentiation?
A) ^
B) ** ✓
C) //
D) %
10. What is the purpose of the if __name__ == "__main__": statement?
A) To ensure a script runs only if it is the main program being executed. ✓
B) To define the main function of a program.
C) To check if the user is running Python 3.
D) To import a module safely.
11. What does the open() function's 'w' mode do?
A) Opens a file for reading.
B) Opens a file for appending.
,C) Opens a file for writing (truncates the file first). ✓
D) Opens a file for both reading and writing.
12. Which collection is unordered and does not allow duplicate elements?
A) List
B) Tuple
C) Set ✓
D) Dictionary
13. What is the output?
python
my_list = [1, 2, 3, 4]
print(my_list[1:3])
A) [1, 2]
B) [2, 3] ✓
C) [1, 2, 3]
D) [2, 3, 4]
14. How do you create a tuple with a single element?
A) t = (1)
B) t = 1,
C) t = (1,) ✓
D) t = tuple(1)
15. What keyword is used to handle exceptions?
A) catch
B) throw
C) try and except ✓
D) error
16. What will the following code print?
python
for i in range(3):
print(i, end=' ')
A) 0 1 2 ✓
B) 1 2 3
, C) 0 1 2 3
D) 1 2
17. Which method is used to remove a key-value pair from a dictionary?
A) remove()
B) pop() ✓
C) delete()
D) discard()
18. What is the correct way to import only the sqrt function from the math module?
A) import math.sqrt
B) import sqrt from math
C) from math import sqrt ✓
D) from math sqrt
19. What is a correct example of a dictionary?
A) {1, 2, 3}
B) [1: 'a', 2: 'b']
C) {'name': 'Alice', 'age': 30} ✓
D) ('a', 'b', 'c')
20. What does the strip() method do for a string?
A) Splits the string into a list.
B) Removes leading and trailing whitespace. ✓
C) Converts the string to uppercase.
D) Reverses the string.
21. What is the output of bool("False")?
A) False
B) True ✓
C) None
D) An error
22. Which of these is a valid f-string?
A) f"My name is {name}" ✓
B) "fMy name is {name}"
C) f"My name is (name)"
D) "My name is f{name}"
23. What is the scope of a variable defined inside a function?
A) Global
OBJECTIVE ASSESSMENT ACTUAL EXAM 2025/2026
QUESTIONS WITH VERIFIED CORRECT SOLUTIONS ||
100% GUARANTEED PASS <BRAND NEW VERSION>
WGU D335 Python Practice Exam
1. What is the output of the following code?
python
x=5
y=2
result = x // y
print(result)
A) 2.5
B) 2 ✓
C) 3
D) 2.0
2. Which data type is mutable in Python?
A) int
B) str
C) tuple
D) list ✓
3. What keyword is used to define a function in Python?
A) func
B) define
C) def ✓
D) function
4. What will print(type(10.0)) output?
A) <class 'int'>
B) <class 'float'> ✓
C) <class 'double'>
D) <class 'number'>
,5. Which of the following is a valid variable name?
A) 2nd_var
B) my-variable
C) _my_var ✓
D) global
6. What does the append() method do?
A) Adds an element to the beginning of a list.
B) Adds an element to the end of a list. ✓
C) Removes the last element of a list.
D) Sorts the list in ascending order.
7. How do you start a single-line comment in Python?
A) //
B) /*
C) # ✓
D) --
8. What is the result of "hello" + "world"?
A) hello world
B) helloworld ✓
C) "hello"+"world"
D) An error
9. Which operator is used for exponentiation?
A) ^
B) ** ✓
C) //
D) %
10. What is the purpose of the if __name__ == "__main__": statement?
A) To ensure a script runs only if it is the main program being executed. ✓
B) To define the main function of a program.
C) To check if the user is running Python 3.
D) To import a module safely.
11. What does the open() function's 'w' mode do?
A) Opens a file for reading.
B) Opens a file for appending.
,C) Opens a file for writing (truncates the file first). ✓
D) Opens a file for both reading and writing.
12. Which collection is unordered and does not allow duplicate elements?
A) List
B) Tuple
C) Set ✓
D) Dictionary
13. What is the output?
python
my_list = [1, 2, 3, 4]
print(my_list[1:3])
A) [1, 2]
B) [2, 3] ✓
C) [1, 2, 3]
D) [2, 3, 4]
14. How do you create a tuple with a single element?
A) t = (1)
B) t = 1,
C) t = (1,) ✓
D) t = tuple(1)
15. What keyword is used to handle exceptions?
A) catch
B) throw
C) try and except ✓
D) error
16. What will the following code print?
python
for i in range(3):
print(i, end=' ')
A) 0 1 2 ✓
B) 1 2 3
, C) 0 1 2 3
D) 1 2
17. Which method is used to remove a key-value pair from a dictionary?
A) remove()
B) pop() ✓
C) delete()
D) discard()
18. What is the correct way to import only the sqrt function from the math module?
A) import math.sqrt
B) import sqrt from math
C) from math import sqrt ✓
D) from math sqrt
19. What is a correct example of a dictionary?
A) {1, 2, 3}
B) [1: 'a', 2: 'b']
C) {'name': 'Alice', 'age': 30} ✓
D) ('a', 'b', 'c')
20. What does the strip() method do for a string?
A) Splits the string into a list.
B) Removes leading and trailing whitespace. ✓
C) Converts the string to uppercase.
D) Reverses the string.
21. What is the output of bool("False")?
A) False
B) True ✓
C) None
D) An error
22. Which of these is a valid f-string?
A) f"My name is {name}" ✓
B) "fMy name is {name}"
C) f"My name is (name)"
D) "My name is f{name}"
23. What is the scope of a variable defined inside a function?
A) Global