









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 17
This page cannot be seen from the preview
Don't miss anything!










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.
M Variables, Data Types & Type Conversionultiple choice.
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
D) 5 Answer: B. 8
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
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]
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"
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