PROGRAMMING (PYTHON) OA 2026 MIDTERM EXAM REVIEW QUESTION AND ANSWER, Exams of Computer Science

Ace the WGU E010 Foundations of Programming (Python) OA midterm Exam review with practice questions covering variables, data types, input/output, arithmetic operators, strings, lists, dictionaries, conditionals, loops, functions, and basic debugging. 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

Tutor-Elias
Tutor-Elias 🇺🇸

2.4K documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1 of 17
PROGRAMMING (PYTHON) OA 2026
MIDTERM EXAM REVIEW COMPLETE (50)
CURRENT TESTING QUESTIONS AND
CORRECT ANSWERS WITH DETAILED
EXPLANATIONS|GUARANTEED PASS.
PYTHON
Ace the WGU E010 Foundations of Programming (Python) OA
midterm Exam review with practice questions covering variables,
data types, input/output, arithmetic operators, strings, lists,
dictionaries, conditionals, loops, functions, and basic debugging.
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.
Variables, Data Types & Type Conversion
1. Which is a valid variable name in Python?
A) 2var
B) my-var
C) _myVar
D) my var
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download PROGRAMMING (PYTHON) OA 2026 MIDTERM EXAM REVIEW QUESTION AND ANSWER and more Exams Computer Science in PDF only on Docsity!

MIDTERM EXAM REVIEW COMPLETE (50)^ PROGRAMMING (PYTHON) OA 2026

CORRECT ANSWERS WITH DETAILED^ CURRENT TESTING QUESTIONS AND

EXPLANATIONS|GUARANTEED PASS.

Ace the WGU E010 Foundations of Programming (Python) OA^ PYTHON

midterm Exam data types, input/output, arithmetic operators, strings, lists, review with practice questions covering variables, dictionaries, conditionals, loops, functions, and basic debugging. This study guide helps reinforce foundational coding concepts and supports effec to improve problemtive preparation for objective assessments. Designed-solving skills and boost confidence in Python programming. Suitable for computer science, IT, and programming students.

Multiple choice. Variables, Data Types & Type Conversion

  1. Which is a valid variable name in Python? A) 2var B) C) my_myVar-var D) my var

Answer: C. 2. What is the data type of _myVar 3.0? A) int B) float C) str D) bool Answer: B. float 3. What does print(type(5 // 2)) output? A) B) C) D) Error Answer: A. 4. Which function converts the string (floor division returns integer) "123" to an integer? A) B) int("123")str("123") C) D) float("123")bool("123") Answer: A. 5. What is the Boolean value of int("123") bool([])? A) True B) False C) None D) Error

B) 8 C) 9

D) 5 Answer: B. 8

  1. Which operator means “not equal to”? A) = B) C) ==!= D) Answer: C. <> !=
  2. What does^ Strings & String Methods "Hello" + "World" produce? A) B) Hello WorldHelloWorld C) D) Error Hello+World Answer: B. 12. Which method removes whitespace from both ends of a HelloWorld string? A) strip() B) C) trim()rstrip() D) split()

Answer: A. 13. What is the output of strip() print("Python"[2:5])? A) B) Pytyth C) D) thohon Answer: C. 14. Which method converts a string to uppercase? tho A) B) upper()uppercase() C) D) toUpper()capitalize() Answer: A. 15. What does upper() len("Hello") return? A) 4 B) 5 C) 6 D) Error Answer: B. 5

  1. Which creates a list with elements 1, 2, 3?^ Lists & List Operations A) list(1, 2, 3)

x = [1, 2, 3] y = x y.append(4) print(x) A) B) [1, 2, 3][1, 2, 3, 4] C) D) Error [4] Answer: B. [1, 2, 3, 4]

  1. How do you create a dictionary with key^ Dictionaries "name" and value A) {"name": "Alice"} "Alice"? B) C) "name": "Alice" D) Answer: A. {"name" = "Alice"} {"name": "Alice"}
  2. How do you access the value for key dictionary person? "age" in A) B) person["age"]person("age")

C) D) person{"age"}person.age Answer: A. 23. Which method returns all keys of a dictionary? person["age"] A) B) keys()values() C) D) items()get() Answer: A. 24. Which of the following adds the key keys() "city" with value A) person.add("city", "Boston") "Boston" to dictionary person? B) C) person["city"] = "Boston"person.update("city", "Boston") D) Answer: B. person.city = "Boston" person["city"] = "Boston"

  1. Which error occurs when you access a missing key with square brackets? A) B) NameErrorTypeError C) D) KeyErrorIndexError Answer: C. KeyError
  1. How do you test if A) if 10 < n < 20: n is between 10 and 20 inclusive? B) C) if 10 <= n <= 20:if n > 10 and n < 20: D) Answer: B. if n in range(10, 20): if 10 <= n <= 20:
  2. What is the output of A) True print(True and False)? B) False C) 1 D) 0 Answer: B. False
  3. What is the output of A) True print(not(5 > 3))? B) False C) None D) Error Answer: B. False
  4. How many times does the loop run?^ Loops python i = 0

while i < 5: i += 1 A) 4 B) 5 C) 6 D) infinite Answer: B. 5 32. What does range(3) produce? A) 0,1,2 B) 1,2, C) 0,1,2,3 D) 1,2,3, Answer: A. 0,1,2 33. Which keyword exits a loop immediately? A) B) exitbreak C) D) continuestop Answer: B. 34. What is the output? break python for i in range(1, 5): if i == 3:

python def add(a, b):

print(add(3, 4))^ return a + b A) 7 B) 12 C) 34 D) Error Answer: A. 7 38. A return statement without a value returns what? A) B) (^0) None C) D) Error False Answer: B. 39. Which call is valid for None def greet(name="Guest")? A) B) greet()greet("Alice") C) Both A and B D) Neither Answer: C. Both A and B 40. What is the output? python

def add(x, y=10): return x + y print(add(5)) A) 5 B) 10 C) 15 D) Error Answer: C. 15

🖨️ 41. Which function reads user input as a string? Input/Output A) B) read()input() C) D) get()scan() Answer: B. 42. What is the effect of input() end="" in print()? A) Adds a space at the end B) Suppresses the newline C) Prints nothing D) Adds a comma Answer: B. Suppresses the newline

C) D) random.random(1, 10)random.choice(1, 10) Answer: B. 47. What is the output of random.randint(1, 10) print(10 % 4)? A) 2 B) 2. C) 2.0 D) 0. Answer: A. 2 48. How do you create an empty list? A) B) list()[] C) Both A and B D) None Answer: C. Both A and B 49. How do you swap a and b? A) B) a = b; b = aa, b = b, a C) D) swap(a, b)a = b; b = a (same as A) Answer: B. 50. What is the output of a, b = b, a print("Hello" * 2)? A) HelloHello B) Hello

C) Error D) Hello Hello Answer: A. HelloHello