• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 81 pages
Exam (elaborations)

WGU D335 – Introduction To Programming In Python Exam | Practice Questions And Answers 2026/2027 | Complete Questions And Answers (Verified Answers) | Exam Prep | Comprehensive Exam Guide 2026&2027

Document preview thumbnail
Preview 4 out of 81 pages

WGU D335 – Introduction To Programming In Python Exam | Practice Questions And Answers 2026/2027 | Complete Questions And Answers (Verified Answers) | Exam Prep | Comprehensive Exam Guide 2026&2027

Content preview

WGU D335 – Introduction To Programming In Python
Exam | Practice Questions And Answers 2026/2027 |
Complete Questions And Answers (Verified Answers) |
Exam Prep | Comprehensive Exam Guide 2026&2027
1. A Python program needs to store a customer's age so that arithmetic operations can be
performed on it later. Which data type is most appropriate?

A. str
B. int
C. bool
D. list

Answer: B

An int stores whole numbers and is therefore appropriate for an age that will be used in
arithmetic calculations.

2. A developer wants to display the value stored in the variable name to the console. Which
statement should be used?

A. print(name)
B. display = name
C. console(name)
D. output.name()

Answer: A

The built-in print() function writes the value of its argument to standard output.

3. A program receives the text "42" from user input and needs to add 8 to it numerically.
Which operation is required first?

A. str(42)
B. bool("42")
C. int("42")
D. list("42")

Answer: C

input() returns text, so int() converts the numeric string "42" into the integer 42 before
arithmetic is performed.

,4. Which Python expression evaluates to True?

A. 5 < 2
B. 10 == 10
C. 7 != 7
D. 3 > 9

Answer: B

The equality comparison 10 == 10 is true because both operands have the same value.

5. A developer needs to execute a block only when a customer's balance is greater than
zero. Which construct is appropriate?

A. if
B. for
C. import
D. return

Answer: A

An if statement conditionally executes a block when its Boolean condition evaluates to true.

6. What is the value of result after the following code executes? result = 17 // 5

A. 2
B. 3
C. 3.4
D. 4

Answer: B

The // operator performs floor division. Seventeen divided by five is 3 with a remainder of 2,
so the result is 3.

7. A program must repeat an operation exactly 10 times using a known sequence of
iterations. Which approach is most appropriate?

A. if
B. try
C. for
D. except

Answer: C

,A for loop is well suited to iterating a known number of times or iterating over a sequence or
range.

8. Which value is returned by len("Python")?

A. 5
B. 6
C. 7
D. 8

Answer: B

The string "Python" contains six characters, so len() returns 6.

9. A developer wants to access the first element of the list colors = ["red", "blue",
"green"]. Which expression should be used?

A. colors[0]
B. colors[1]
C. colors[-1]
D. colors.first()

Answer: A

Python sequences use zero-based indexing, so index 0 identifies the first element.

10. Which collection is specifically designed to store key-value pairs?

A. Tuple
B. Set
C. Dictionary
D. String

Answer: C

A dictionary stores data as key-value pairs, allowing values to be retrieved through their
associated keys.

11. A program must prevent modification of a collection after it is created. Which built-in
collection type is most appropriate?

A. List
B. Tuple
C. Dictionary
D. Set

, Answer: B

Tuples are immutable sequences, meaning their elements cannot be reassigned after
creation.

12. What does the expression 7 % 3 return?

A. 0
B. 1
C. 2
D. 3

Answer: C

The modulus operator % returns the remainder after division. Seven divided by three leaves a
remainder of two.

13. A developer wants to execute one block when a condition is true and another block
when it is false. Which construct is appropriate?

A. if...else
B. for...in
C. try...finally
D. while...continue

Answer: A

The if...else structure provides two alternative execution paths based on a Boolean condition.

14. Which statement correctly defines a function named calculate_total with no
parameters?

A. function calculate_total():
B. define calculate_total():
C. def calculate_total():
D. func calculate_total():

Answer: C

Python functions are defined with the def keyword followed by the function name and
parameter list.

15. A function must send a calculated value back to the caller. Which keyword should it
use?

Document information

Uploaded on
September 18, 2026
Number of pages
81
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$22.79

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

Sold
10
Followers
1
Items
1385
Last sold
1 day ago



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