Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

WGU D335 – Introduction to Programming in Python (2025/2026) | PRE-assessment Updated Questions and Answers | 100% Score | 71Q&A

Rating
-
Sold
-
Pages
25
Grade
A+
Uploaded on
30-11-2025
Written in
2025/2026

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 % addition uses &, subtraction uses -, multiplication uses #, division uses /, and 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_(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. 7. Which of the following statements is False about the Python module? 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('', 'r') as file: content = () print(content) To ensure the file is properly closed after its suite finishes, even if an error is raised. To create a new file if it does not exist. To read the file line by line instead of all at once. To open the file in write mode instead of read mode. 11. Which is the best way to get a number from the user that you can use in an equation? num = int(input("Enter a number: ")) num = str(input("Enter a number: ")) num = number(input("Enter a number: ")) num = input("Enter a number: ") 12. A list in Python is Mutable Ordered & indexable Composed of unique elements Composed of key-value pairs 13. Assume that a file was opened and its handle was stored in the variable "infile". Which of the following is a valid way to close that file? () close('some_') close(infile) infile = open_file('some_', 'r') 14. In which scenario would you use a break statement? When you want to skip the current iteration When you want to repeat the current iteration When you want to exit the loop immediately When you want to count the number of iterations 15. What is the purpose of the replace() method in Python strings? To concatenate two strings To remove a substring from a string To replace a specified substring with another substring To convert a string to uppercase 16. Which of the following Python modules is specifically designed to provide support for precise decimal arithmetic? math locale decimal random 17. What is the purpose of the break statement in Python? To exit a loop early if a certain condition is met. To skip over an iteration of a loop if a certain condition is met. To repeat a block of code a specific number of times. To generate a sequence of numbers. 18. In a Python loop, what is the purpose of the 'continue' statement? To terminate the loop immediately To skip the current iteration and continue with the next To pause the loop execution To repeat the current iteration 19. What is the primary function of the '==' operator in Python? Compares two values for equality Assigns the value of the right-hand operand to the left-hand operand Checks if two variables are not equal Performs addition on two numbers 20. What is a function in Python? Code block that is reusable and performs different actions. A program that performs an action. Code block that is reusable and performs an action.

Show more Read less
Institution
Course

Content preview

11/30/25, :11:04 AM
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

Written for

Course

Document information

Uploaded on
November 30, 2025
Number of pages
25
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$11.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF


Also available in package deal

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
MENTALGIANT Western Governors University
Follow You need to be logged in order to follow users or courses
Sold
493
Member since
4 year
Number of followers
385
Documents
269
Last sold
6 days ago
ALL UNIVERSITY FINAL EXAMs, OAs, PAs, NURSING EXAMS AND TESTBANKS NB: REVIEWING GETS CHEAPER PRICES

ALL UNIVERSITY FINAL EXAMs, OAs, PAs, NURSING EXAMS AND TESTBANKS/ STUDY GUIDES(Verified learners) Here, you will find everything you need in ALL UNIVERSITY FINAL EXAMs, OAs, PAs, NURSING EXAMS AND TESTBANKS.Contact us, to fetch it for you in minutes if we do not have it in this shop.BUY WITHOUT DOUBT!!!!Always leave a review after purchasing any document so as to make sure our customers are 100% satisfied.

3.5

92 reviews

5
38
4
10
3
19
2
10
1
15

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions