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

Ace the WGU E010 Foundations of Programming (Python) OA practice Exam with practice questions covering Python syntax, data types, control structures, functions, data structures (lists, tuples, dictionaries, sets), file I/O, exception handling, modules, and basic object-oriented programming. 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/18/2026

Elaboratedexams
Elaboratedexams 🇿🇦

2.4K documents

1 / 44

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1 of 44
WGU E010 FOUNDATIONS OF
PROGRAMMING (PYTHON) OA 2026
PRACTICE EXAM COMPLETE (100) CURRENT
TESTING QUESTIONS AND CORRECT
ANSWERS WITH DETAILED
EXPLANATIONS|GUARANTEED PASS.
PYTHON
Ace the WGU E010 Foundations of Programming (Python) OA practice
Exam with practice questions covering Python syntax, data types,
control structures, functions, data structures (lists, tuples,
dictionaries, sets), file I/O, exception handling, modules, and basic
object-oriented programming. 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.
Section 1: Python Fundamentals & Syntax (Questions 115)
1. What is the correct output of the following Python code?
print("Hello, World!")
A) Hello, World!
B) Hello, World!
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c

Partial preview of the text

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

WGU E010 FOUNDATIONS OF

PROGRAMMING (PYTHON) OA 2026

PRACTICE EXAM COMPLETE (100) CURRENT

TESTING QUESTIONS AND CORRECT

ANSWERS WITH DETAILED

EXPLANATIONS|GUARANTEED PASS.

PYTHON

Ace the WGU E010 Foundations of Programming (Python) OA practice Exam with practice questions covering Python syntax, data types, control structures, functions, data structures (lists, tuples, dictionaries, sets), file I/O, exception handling, modules, and basic object-oriented programming. 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. Section 1: Python Fundamentals & Syntax (Questions 1–15)

1. What is the correct output of the following Python code? print("Hello, World!") A) Hello, World! B) Hello, World!

C) print("Hello, World!") D) An error occurs Answer: A. Hello, World! Explanation: The print() function outputs the string literal to the console without the quotation marks. The quotes are used only to denote the string.

2. Which of the following is a valid variable name in Python? A) 2_variable B) my-variable C) _myVariable D) my variable Answer: C. _myVariable **Explanation: Variable names can start with a letter or underscore, cannot start with a digit, and cannot contain spaces or hyphens. Underscore is allowed.

  1. In Python, which symbol is used for single-line comments?** A) // B) # C) /* D) Answer: B. Explanation: type() returns the class of the object. 3.14 is a floating-point number, so the output indicates a float class.

7. Which operator is used for exponentiation (power) in Python? A) ^ B) ** C) * D) // Answer: B. ** Explanation: ** is the exponentiation operator (e.g., 2 ** 3 equals 8). The ^ **operator is used for bitwise XOR.

  1. What is the result of** 17 // 5 in Python? A) 3. B) 3 C) 4 D) 3. Answer: B. 3 Explanation: // **is the floor division operator; it returns the integer quotient, discarding the remainder (17 // 5 = 3).
  2. What is the output of** print(10 % 3)? A) 3. B) 1 C) 3 D) 10

Answer: B. 1 Explanation: % is the modulo operator; it returns the remainder of division (10 divided by 3 gives remainder 1).

10. Which of the following correctly converts the string "123" to an integer? A) int("123") B) integer("123") C) str(123) D) "123".to_int() Answer: A. int("123") Explanation: The built-in int() **function converts a string (or other numeric type) to an integer, provided the string represents a valid integer.

  1. What is the value of** len("Python")? A) 5 B) 6 C) 7 D) 4 Answer: B. 6 Explanation: len() **returns the number of characters in the string. "Python" has 6 characters: P, y, t, h, o, n.
  2. Which statement reads input from the user as a string?** A) input("Enter name: ") B) read("Enter name: ")

15. What does bool(0) return? A) True B) False C) 0 D) None Answer: B. False Explanation: In Python, numeric values: 0, 0.0, and complex zero evaluate to False in a Boolean context. All non-zero numbers evaluate to True**. Section 2: Control Flow (if, elif, else, loops) (Questions 16–30)

  1. What is the output of the following code?** python x = 10 if x > 5: print("A") elif x > 7: print("B") else: print("C") A) A B) B

C) C

D) No output Answer: A. A Explanation: The first condition x > 5 is True (10 > 5), so the block under if executes and prints "A". The elif and else blocks are skipped.

17. Which logical operator would be used to check if both conditions a > 5 and b < 10 are True? A) or B) and C) not D) & Answer: B. and Explanation: The and operator returns True only when both operands are True**. This matches the requirement that both conditions must hold.

  1. How many times will the following loop execute?** python count = 0 while count < 5: count += 1 A) 4 B) 5

Answer: C. break Explanation: The break statement terminates the innermost loop (while or for) immediately and resumes execution after the loop.

21. What is the output of the following code? python for i in range(1, 6, 2): print(i, end=" ") A) 1 2 3 4 5 B) 1 3 5 C) 2 4 6 D) 1 3 5 7 Answer: B. 1 3 5 Explanation: range(1, 6, 2) **starts at 1, goes up to but not including 6, with a step of 2. So the values are 1, 3, and 5.

  1. Which of the following correctly checks if a number** n is between 10 and 20 (inclusive)? A) 10 <= n <= 20 B) n >= 10 and n <= 20 C) Both A and B D) n in range(10,20) Answer: C. Both A and B Explanation: Python supports chained comparisons: 10 <= n

<= 20 is equivalent to n >= 10 and n <= 20. range(10,20) excludes 20, so it's not inclusive of 20.

23. What is the output of print(not (5 > 3) or (2 == 2))? A) False B) True C) None D) Error Answer: B. True Explanation: (5 > 3) is True, so not True is False. (2 == 2) is True. False or True **evaluates to True.

  1. Which loop is guaranteed to execute at least once?** A) for loop B) while loop C) do-while loop (Python does not have one) D) none of the above Answer: D. none of the above Explanation: Python has no do-while loop. Both for and while **loops check conditions before the first iteration, so they may execute zero times.
  2. What is the value of** x after the following? python x = 5 if x: x = 10

break print(i, end=" ") A) 0 B) 0 1 C) 0 1 2 D) No output Answer: A. 0 Explanation: When i = 0, condition false, print 0. When i = 1, i == 1 is True, break exits the loop immediately without printing 1 or further values.

28. How many times will "Hello" be printed? python i = 0 while i < 5: print("Hello") i += 2 A) 2 B) 3 C) 4 D) 5 Answer: B. 3 Explanation: i starts 0 → print, i=2; i=2 → print, i=4; i=4 → print, i=6; now i=6 not <5, stop. Three prints.

29. Which expression evaluates to True if age is NOT between 18 and 65 inclusive? A) age < 18 or age > 65 B) not (18 <= age <= 65) C) both A and B D) age not in range(18,66) Answer: C. both A and B Explanation: Both correctly represent the condition. range(18,66) includes 65, so age not in range(18,66) **also works but is less common for numeric comparisons.

  1. What is the output of the following nested loop?** python for i in range(2): for j in range(2): print(i*j, end=" ") A) 0 0 0 1 B) 0 1 0 1 C) 0 0 0 0 D) 0 1 1 2 Answer: A. 0 0 0 1 Explanation: Outer loop i=0, inner loop j=0 → 0; j=1 → 0; outer i=1, inner j=0 → 0; j=1 → 1. So output: 0 0 0 1.

python def add(a, b): return a + b result = add(3, 4) print(result) A) 7 B) 12 C) add(3,4) D) Error Answer: A. 7 Explanation: The function takes two parameters and returns their sum. add(3,4) returns 7, which is assigned to result and printed.

34. A variable defined inside a function is called a __________ variable. A) global B) local C) static D) constant **Answer: B. local Explanation: Variables declared inside a function have local scope; they are not accessible outside that function unless returned or passed.

  1. What is the output?**

python x = 10 def change(): x = 20 change() print(x) A) 10 B) 20 C) None D) Error Answer: A. 10 Explanation: Inside change() , x = 20 creates a local variable x that shadows the global x. The global x remains unchanged, so print(x) outputs 10.

36. How do you make a function return a value without using return? A) It's impossible; functions without return return None B) Use yield C) Use print() D) Use pass Answer: A. It's impossible; functions without return return None Explanation: If no return statement is executed, or a return with no value, the function returns None implicitly.

tuple. **kwargs collects keyword arguments into a dictionary.

39. What is the output? python def func(x, y=2, z=3): return x + y + z print(func(1, z=4)) A) 6 B) 7 C) 8 D) Error Answer: B. 7 Explanation: x=1 (positional), y uses default 2, z **is overridden to 4. Sum = 1+2+4 = 7.

  1. Which of the following is a valid way to call a function defined as** def multiply(a, b):? A) multiply(2)(3) B) multiply(2, 3) C) multiply(a=2, b=3) D) Both B and C Answer: D. Both B and C Explanation: You can call using positional arguments ( multiply(2,3) ) or keyword arguments ( multiply(a=2,b=3) ).

41. What is the scope of a variable defined inside a function? A) Global B) Local to that function C) Enclosing function only if nested D) Both B and C **Answer: D. Both B and C Explanation: A variable defined inside a function is local to that function. If the function is nested inside another function, it is local to the inner function and can be accessed by the inner function (but not by the outer function).

  1. What will the following code print?** python def outer(): x = "local" def inner(): nonlocal x x = "nonlocal" inner() print(x) outer() A) local B) nonlocal