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
Document preview thumbnail
Preview 4 out of 156 pages
Exam (elaborations)

WGU E010 (D335) FOUNDATIONS OF PROGRAMMING (PYTHON) FINAL EXAM QUESTIONS WITH DETAILED- VERIFIED ANSWERS- ALREADY GRADED A+ || NEWEST EXAM

Document preview thumbnail
Preview 4 out of 156 pages

WGU E010 (D335) FOUNDATIONS OF PROGRAMMING (PYTHON) FINAL EXAM QUESTIONS WITH DETAILED- VERIFIED ANSWERS- ALREADY GRADED A+ || NEWEST EXAM Computer Science / Information Technology This WGU E010 (D335) Foundations of Programming (Python) exam covers variables, data types, type conversion, operators (arithmetic, comparison, logical, assignment), strings (slicing, methods, formatting), lists, tuples, dictionaries, sets (mutability, operations), conditionals (if/elif/else, ternary), loops (for, while, break, continue, else), functions (definition, parameters, return, scope, lambda, recursion), file I/O (open, read, write, append, with context), exception handling (try/except/else/finally, raise), and modules (import, math, random, os, sys).

Content preview

Page 1 of 156


WGU E010 (D335) FOUNDATIONS OF PROGRAMMING (PYTHON)
FINAL EXAM QUESTIONS WITH DETAILED- VERIFIED ANSWERS-
ALREADY GRADED A+ || NEWEST EXAM 2025-2026
Computer Science / Information Technology
This WGU E010 (D335) Foundations of Programming (Python) exam
covers variables, data types, type conversion, operators (arithmetic,
comparison, logical, assignment), strings (slicing, methods, formatting),
lists, tuples, dictionaries, sets (mutability, operations), conditionals
(if/elif/else, ternary), loops (for, while, break, continue, else), functions
(definition, parameters, return, scope, lambda, recursion), file I/O (open,
read, write, append, with context), exception handling
(try/except/else/finally, raise), and modules (import, math, random, os,
sys).
SECTION 1 – VARIABLES, DATA TYPES, AND OPERATORS (Q1–25)
1. A student writes the following code to calculate the total price of
items, but the output is not as expected. The price per item is $12.50,
and the quantity is 4. The code is:


python
price = "12.50"
quantity = 4
total = price * quantity
print(total)
What is printed, and what is the error?

, Page 2 of 156


A) 50.0 – the code works correctly because strings convert automatically.
B) "12.5012.5012.5012.50" – the string is repeated four times instead of
numeric multiplication.
C) 12.50 * 4 – the expression is printed literally.
D) Error – you cannot multiply a string by an integer.


CORRECT ANSWER: B
Rationale: Multiplying a string by an integer repeats the string. Since
price is a string ("12.50"), not a float, the result is the string repeated four
times. To fix, convert to float: float(price) * quantity.


2. A programmer needs to swap the values of two variables a and b.
Which of the following code snippets correctly swaps them without
using a temporary variable?


A)


python
a=b
b=a
B)


python

, Page 3 of 156


a, b = b, a
C)


python
a=a+b
b=a-b
a=a-b
D) Both B and C are correct in Python.


CORRECT ANSWER: D
Rationale: Python's tuple unpacking (a, b = b, a) is the standard way.
Arithmetic method also works for numbers but fails for strings or if
overflow occurs. Both B and C produce a correct swap.


3. What is the output of the following code?


python
x=7%3
y = 7 // 3
print(x, y)
A) 1 2
B) 2 1
C) 1 2.333

, Page 4 of 156


D) 2.333 2


CORRECT ANSWER: A
Rationale: % gives remainder: 7 ÷ 3 = 2 remainder 1 → x = 1. // gives floor
division: 7 // 3 = 2. Output is 1 2.


4. A student is asked to write an expression that returns True if a number
stored in variable n is within the range 10 to 20 inclusive. Which
expression is correct?


A) 10 <= n <= 20
B) 10 <= n and n <= 20
C) n >= 10 and n <= 20
D) All of the above.


CORRECT ANSWER: D
Rationale: Python supports chained comparisons. All three expressions
evaluate the same way and return True if n is between 10 and 20
inclusive.


5. Consider the code:


python

Document information

Uploaded on
June 11, 2026
Number of pages
156
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$27.49

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
0
Followers
0
Items
122
Last sold
-




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