WGU E010 FOUNDATIONS OF PROGRAMMING (PYTHON) OA 2026 FINAL EXAM QUESTION AND ANSWER, Exams of Computer Science

Ace the WGU E010 Foundations of Programming (Python) OA Final Exam with practice questions covering Python data types, control structures, functions, data structures, string operations, and common built-in functions. This study guide helps reinforce foundational coding concepts and supports effective preparation for objective assessments. Designed to improve problem-solving skills and boost confidence in Python programming. Suitable for computer science, IT, and programming students.

Typology: Exams

2025/2026

Available from 05/17/2026

BETHMIDWIFE
BETHMIDWIFE 🇰🇪

3K documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1 of 23
WGU E010 FOUNDATIONS OF
PROGRAMMING (PYTHON) OA 2026 FINAL
EXAM COMPLETE (50) CURRENT TESTING
QUESTIONS AND CORRECT ANSWERS WITH
DETAILED EXPLANATIONS|GUARANTEED
PASS.
PYTHON
Ace the WGU E010 Foundations of Programming (Python) OA Final
Exam with practice questions covering Python data types, control
structures, functions, data structures, string operations, and
common built-in functions. This study guide helps reinforce
foundational coding concepts and supports effective preparation for
objective assessments. Designed to improve problem-solving skills
and boost confidence in Python programming. Suitable for computer
science, IT, and programming students.
Multiple choice.
Data Types & Type Conversion
1. What is the output of the following code?
python
print(type(10 / 2))
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download WGU E010 FOUNDATIONS OF PROGRAMMING (PYTHON) OA 2026 FINAL EXAM QUESTION AND ANSWER and more Exams Computer Science in PDF only on Docsity!

WGU E010 FOUNDATIONS OF

PROGRAMMING (PYTHON) OA 2026 FINAL

EXAM COMPLETE ( 5 0) CURRENT TESTING

QUESTIONS AND CORRECT ANSWERS WITH

DETAILED EXPLANATIONS|GUARANTEED

PASS.

PYTHON

Ace the WGU E010 Foundations of Programming (Python) OA Final Exam with practice questions covering Python data types, control structures, functions, data structures, string operations, and common built-in functions. This study guide helps reinforce foundational coding concepts and supports effective preparation for objective assessments. Designed to improve problem-solving skills and boost confidence in Python programming. Suitable for computer science, IT, and programming students. Multiple choice. Data Types & Type Conversion

1. What is the output of the following code? python print(type(10 / 2))

A) B) C) D) Answer: B. Explanation: In Python, the / operator always returns a float, even when the two numbers divide evenly. 10 / 2 evaluates to 5.0, which is a float.

2. Which of the following data types is immutable? A) list B) dict C) set D) tuple Answer: D. tuple Explanation: Tuples cannot be changed after they are created. Lists, dictionaries, and sets are mutable. 3. What is the result of print(10 // 3)? A) 3.333… B) 3 C) 4 D) 3. Answer: B. 3 Explanation: The // operator performs floor division (integer division). It returns the quotient without the remainder, so 10 // 3 evaluates to 3.

7. What is the output of print("a" + "b" * 2)? A) ab B) abb C) bab D) Error Answer: B. abb Explanation: Multiplication (*) has higher precedence than addition (+). First, "b" is repeated twice ("bb"), then concatenated with "a". **Indexing, Slicing & String Methods

  1. Given** x = "Hello" , what does print(x[1]) output? A) H B) e C) l D) o Answer: B. e Explanation: Strings are zero-indexed. Index 0 → H, index 1 → e. 9. What is the output of print("Python"[2:5])? A) Pyt B) tho C) yth D) hon

Answer: B. tho Explanation: Slicing [2:5] takes characters from index 2 up to (but not including) index 5. Indices: P0 y1 t2 h3 o4 n5 → slice "tho".

10. What does print(x[-1]) output if x = [1, 2, 3]? A) 1 B) 2 C) 3 D) Error Answer: C. 3 Explanation: Negative indexing starts from the end of the sequence. - 1 refers to the last element. 11. How do you write a single-line comment in Python? A) // B) # C) D) """ Answer: B. # Explanation: The hash symbol # begins a comment. Everything after it on that line is ignored by the interpreter. **Collections: Lists, Dictionaries & Tuples

  1. What does the** append() method do when called on a list? A) Removes the last item

C) [4]

D) Error Answer: B. [1, 2, 3] Explanation: a[:] creates a shallow copy of a. Changes to the copy do not affect the original list.

15. Which of the following creates a list comprehension? A) [x for x in range(5)] B) (x for x in range(5)) C) {x for x in range(5)} D) x for x in range(5) Answer: A. [x for x in range(5)] Explanation: List comprehensions are enclosed in square brackets []. Parentheses create a generator expression, curly braces create a set comprehension. 16. What does the range(3) function produce? A) [0, 1, 2] B) [1, 2, 3] C) [0, 1, 2, 3] D) (0, 1, 2) Answer: A. [0, 1, 2] Explanation: range(3) generates a sequence of integers starting from 0 up to (but not including) 3. In Python 3, range() returns an iterable, but when printed or converted to a list, it produces [0, 1, 2].

Loops & Conditionals

17. Which loop is most appropriate when the number of iterations is not known beforehand? A) for loop B) while loop C) nested loop D) foreach loop Answer: B. while loop Explanation: A while loop continues as long as a condition remains true. It is ideal when you do not know how many times the loop should run. 18. What does the break statement do? A) Skips one iteration and continues B) Exits the loop entirely C) Restarts the loop D) Raises an exception Answer: B. Exits the loop entirely Explanation: break immediately terminates the nearest enclosing loop (for or while). Program execution resumes after the loop. 19. Which keyword is used to define a function in Python? A) function B) def C) define D) func

21. Which keyword is used to handle exceptions in Python? A) catch B) try C) error D) exceptify Answer: B. try Explanation: Python uses try/except blocks to handle exceptions. Code that may raise an exception is placed in a try block, and handling code goes in the corresponding except block. **Operators & Expressions

  1. Which operator is not valid in Python 3?** A) // B) % C) <> D) ** Answer: C. <> Explanation: In Python 2, <> was used as a not-equal operator. Python 3 uses != exclusively. <> is invalid in Python 3. 23. What is the output of print(2 ** 3)? A) 6 B) 8

C) 9

D) 5

Answer: B. 8 Explanation: The ** operator raises the left operand to the power of the right operand. 2³ = 8. Object-Oriented Concepts

24. Which keyword is used to define a class in Python? A) function B) class C) object D) struct Answer: B. class Explanation: Classes are defined using the class keyword, followed by the class name and a colon. The class body contains methods and attributes. **List & String Operations

  1. What is the output of the following code?** python sports = ["basketball", "baseball", "football", "soccer", "tennis"] last = sports[-3:]

Answer: B. yth Explanation: [1:4] takes characters from index 1 up to but not including index 4. P0 y1 t2 h3 o4 → "yth". Advanced/Exam-Style Questions

28. Which of the following statements correctly describes how Python executes code? A) Python compiles code into machine language before execution. B) Python is an interpreted language; it reads and executes line by line. C) Python uses a Just-In-Time (JIT) compiler exclusively. D) Python is a fully compiled language like C++. Answer: B. Python is an interpreted language; it reads and executes line by line. Explanation: Python is an interpreted, high-level programming language. It compiles source code into bytecode, which is then executed by the Python Virtual Machine (PVM). 29. Which of the following is a correct way to extract the last three items from a list called data without modifying data? A) data.pop(3) B) data[-3:] C) data[:-3] D) data.clear()

Answer: B. data[-3:] Explanation: Slice notation [-3:] creates a new list containing the last three elements. It does not alter the original list.

30. Given x = "Hello" , what will print(x[-1]) output? A) H B) e C) l D) o Answer: D. o Explanation: Negative indices count from the end of a string. - 1 always returns the last character, which is "o". **More Questions

  1. What is the output of the following code?** python print(type("Hello" * 3)) A) B) C) D) Answer: C. Explanation: Multiplying a string by an integer repeats the string. The result is still a string.

C) int("3.14") D) float("5.0") Answer: C. int("3.14") Explanation: The string must represent a valid integer literal. "3.14" cannot be converted directly to an integer because of the decimal point.

35. What is the output of the following code? python print("Hello" + "World") A) HelloWorld B) Hello World C) Hello+World D) "Hello" + "World" Answer: A. HelloWorld Explanation: The + operator concatenates strings. No space is added unless explicitly included. 36. Which of the following statements about range(5, 10, 2) is correct? A) It generates numbers 5, 6, 7, 8, 9 B) It generates numbers 5, 7, 9 C) It generates numbers 5, 7, 9, 11 D) It generates numbers 5, 10, 15 Answer: B. It generates numbers 5, 7, 9 Explanation: The first argument is the start (5), the second is

the stop (10 – not included), and the third is the step (2). So it yields 5, 7, 9.

37. What is the output of the following code? python print(3 == 3.0) A) True B) False C) Error D) None Answer: A. True Explanation: The == operator compares values, not types. Since 3 and 3.0 represent the same numeric value, the comparison returns True. 38. Which of the following correctly defines a Python function that returns the square of a number? A) def square(x): return x * x B) function square(x) { return x * x; } C) def square(x) { return x * x } D) square(x): return x * x Answer: A. def square(x): return x * x Explanation: Python uses the def keyword, a colon, and indentation to define functions. Braces are not used. 39. What is the output of the following code? python

C) Error D) None Answer: B. False Explanation: The and operator returns True only if both conditions are True. Here, 10 > 5 is True, but 5 > 10 is False, so the overall expression is False.

42. Which of the following correctly reads a line of text from the user and strips the trailing newline? A) input().strip() B) input().split() C) input().read() D) input().stripnewline() Answer: A. input().strip() Explanation: input() returns the user’s input as a string, including a trailing newline. The .strip() method removes leading/trailing whitespace, including the newline character. 43. What is the output of the following code? python print(5 * "Hi") A) HiHiHiHiHi B) Hi repeated 5 times (HiHiHiHiHi) C) 5*Hi D) 5 Hi

Answer: A. HiHiHiHiHi Explanation: Multiplying a string by an integer repeats the string. 5 * "Hi" produces "HiHiHiHiHi".

44. Which of the following statements about Python’s None is true? A) None is the same as 0 B) None is the same as False C) None represents a null value or no value D) None is a reserved keyword for a missing argument Answer: C. None represents a null value or no value Explanation: None is a special constant used to denote the absence of a value or a null value. It is not equivalent to 0, False, or any empty container. 45. What is the output of the following code? python print(len("Python")) A) 5 B) 6 C) 7 D) Error Answer: B. 6 Explanation: The len() function returns the number of characters in a string. "Python" has 6 letters.