WGU D335 – Introduction to Programming in Python 100% SCORE
(2025/2026) | Objective Assessment Updated
Questions and Answers | 100% Score | 71
Score
WGU D335 – Introduction to Programming in Python (2025/2026) | PRE-
assessment Updated Questions and Answers | 100% Score | 71Q&A
1. Which of the following code snippets correctly demonstrates the use of the decimal
module to avoid floating-point precision errors when adding two decimal numbers?
from decimal import Decimal
num1 = Decimal('0.1')
num2 = Decimal('0.2')
result = num1 + num2
print(result)
num1 = 0.1
num2 = 0.2
result = num1 + num2
print(f'Sum: {result}')
from decimal import Decimal
num1 = 0.1
num2 = 0.2
result = Decimal(num1) + Decimal(num2)
print(f'Sum: {result}')
from decimal import Decimal
num1 = Decimal('0.1')
num2 = Decimal('0.2')
result = num1 * num2
print(f'Accurate product using decimal: {result}')
2. The arithmetic operators used in mathematical expressions are as follows ___ _.
addition uses &, subtraction uses $, multiplication uses #, division uses /, and
modulo division uses !
addition uses @, subtraction uses -, multiplication uses *, division uses \, and
modulo division uses %
addition uses +, subtraction uses -, multiplication uses *, division uses /, and
modulo division uses %
WGU D335 – Introduction to Programming in Python 1/25
(2025/2026) | Objective Assessment Updated
Questions and Answers | 100% Score | 71
,11/30/25, :11:04 AM
WGU D335 – Introduction to Programming in Python
(2025/2026) | Objective Assessment Updated
addition uses &, subtraction uses -, multiplication uses #, division uses /, and
Questions and Answers | 100% Score | 71
modulo division uses \
3. What does "slicing" mean in Python?
Extracting a portion of a list, tuple, or string
Removing the first element of a list
Sorting a list in reverse order
Combining two lists into one
4. Which of the following lines of code will print the elements at indices 2, 3, and 4 from
the my_list list?
print (my_list[2:3] )
print (my_list(2:5) )
print (my_list[2:5] )
print (my_list.slice(2, 3) )
5. What is the primary purpose of the pickle module in Python?
To convert Python objects into a byte stream for storage or transmission
To perform mathematical operations on data
To manage file input and output operations
To create graphical user interfaces
6. Which of the following statements a), b), or c) is false?
The Python Standard Library's pickle module can serialize objects into the
data formats of many popular programming languages.
Pickle has potential security issues.
If you write your own pickling and de-pickling code, pickling can be secure.
All of the above statements are true.
WGU D335 – Introduction to Programming in Python 2/25
(2025/2026) | Objective Assessment Updated
Questions and Answers | 100% Score | 71
, 11/30/25, :11:04 AM
WGU D335 – Introduction to Programming in Python
(2025/2026) | Objective Assessment Updated
7. Which of the following statements is False about the Python module?
Questions and Answers | 100% Score | 71
Consider a module to be the same as a code library.
A file containing a set of functions you want to include in your application.
You can import and use built-in modules except for user-defined modules
8. What is the primary purpose of the pickle module in Python?
To read and write CSV files
To serialize and deserialize Python objects
To perform mathematical operations
To manage file input and output
9. Which of the following Python code snippets correctly prompts the user for two
numbers, multiplies them, and displays the product?
def multiply_numbers(): num1 = float(input('Enter the first number: ')) num2 =
float(input('Enter the second number: ')) product = num1 * num2 print(f'The
product of {num1} and {num2} is {product}') multiply_numbers()
def multiply_numbers(): num1 = input('Enter the first number: ') num2 =
input('Enter the second number: ') product = num1 + num2 print(f'The product
of {num1} and {num2} is {product}') multiply_numbers()
def multiply_numbers(): num1 = int(input('Enter the first number: ')) num2 =
int(input('Enter the second number: ')) product = num1 - num2 print(f'The
product of {num1} and {num2} is {product}') multiply_numbers()
def multiply_numbers(): num1 = float(input('Enter the first number: ')) num2 =
float(input('Enter the second number: ')) product = num1 / num2 print(f'The
product of {num1} and {num2} is {product}') multiply_numbers()
10. What is the purpose of the 'with' statement in the following code snippet? with
open('example.txt', 'r') as file: content = file.read() print(content)
To ensure the file is properly closed after its suite finishes, even if an error
is raised.
WGU D335 – Introduction to Programming in Python 3/25
(2025/2026) | Objective Assessment Updated
Questions and Answers | 100% Score | 71