




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Comprehensive Objective^ WGU E010 Foundations of Programming (Python): Assessment Practice Exam Detailed^ 180 Multiple Explanation-Choice Questions with Verified Answers ands Advanced Difficulty | Mixed Content | College/University Level | Aligned with WGU E010 & D335 Curriculum Standards
SECTION 1: PYTHON FUNDAMENTALS, SYNTAX & DATA TYPES (Questions 1-30)
Question 1
What is the correct output of the following Python code? python
Print ("Hello, World!")
A) Hello, World! (without quotes) B) "Hello, World!" (with quotes) C) Print ("Hello, World!") D) An error occurs
☑Correct Answer: A
Explanation: The print () function outputs the string literal to the console without the quotation marks. The quotes are used only to denote the string in the code, not as part of the output.
Question 2
Which of the following is a valid variable name in Python?
A) 2_variable B) my-variable C) _my Variable D) my variable
☑Correct Answer: C
Explanation: Variable names in Python can start with a letter or underscore, cannot start with a digit, and cannot contain spaces or hyphens. _myVariable
Question 4
What is the output of print(type(10 / 2))?
A) B) C) D)
☑Correct Answer: B
Explanation: In Python, the / operator performs true division and always returns a float, even when the numbers divide evenly. 10 / 2 evaluates to 5.0, so type(5.0) returns .
Question 5
Which of the following data types is immutable?
A) list B) dict C) set D) tuple
☑Correct Answer: D
Explanation: Tuples are immutable—once created, they cannot be changed. Lists, dictionaries, and sets are mutable and can be modified after creation. This immutability makes tuples useful as dictionary keys and for representing fixed data.
Question 6
What is the output of the following code?
A) True B) False C) None D) Error
☑Correct Answer: B
Explanation: In Python, the integer 0, empty strings, empty lists, empty dictionaries, None, and False evaluate to False in a boolean context. All other numbers (positive and negative) evaluate to True.
Question 8
What is the output of print(10 // 3)?
A) 3.333... B) 3
☑Correct Answer: B
Explanation: The // operator performs floor division (integer division), returning the quotient without the remainder. 10 // 3 evaluates to 3. This is different from / which returns a float.
Question 9
What is the value of 10 % 3?
A) 1 B) 2 C) 3 D) 0
Explanation: The ** operator is the exponentiation operator. 2 ** 3 means 2 raised to the power of 3, which is 2 * 2 * 2 = 8. This operator has higher precedence than multiplication or division.
Question 11
Which operator checks equality in Python?
A) = B) == C) != D) ===
☑Correct Answer: B
Explanation: == is the equality comparison operator, used to check if two values are equal. = is the assignment operator, != means "not equal", and === is not valid in Python (JavaScript uses strict equality).
Question 12
What is the output of print(5 + 3 * 2)?
A) 16 B) 11 C) 13 D) 10
☑Correct Answer: B
Explanation: Multiplication has higher precedence than addition in Python. 3 * 2 = 6, then 5 + 6 = 11. Operator precedence follows standard mathematical
Question 14
What is the result of bool("False")?
A) False B) True C) Error D) None
☑Correct Answer: B
Explanation: Any non-empty string evaluates to True in a boolean context. The content of the string (even "False") does not matter—only the fact that it is nonempty matters. Empty strings evaluate to False.
Question 15
Which of the following is the correct way to read user input in Python?
A) input() B) read() C) get_input() D) scanf()
☑Correct Answer: A
Explanation: The built-in input() function reads a line from standard input and returns it as a string. read() is used for file operations, and scanf() is from C. The input() function can take an optional prompt string.
Question 16
What is the output of print("5" + "3")?
A) 8
print(x)
A) 5 B) 7 C) 2 D) Error
☑Correct Answer: B
Explanation: The += operator is an augmented assignment operator that adds the right operand to the left operand and assigns the result to the left variable. x += 2 is equivalent to x = x + 2, so 5 + 2 = 7.
Question 18
Which of the following is the correct way to create an empty list?
A) list()
C) Both A and B D) None of the above
☑Correct Answer: C
Explanation: Both [] and list() create an empty list. The [] syntax is the preferred and more commonly used method. This is the standard way to initialize an empty list for later population.
Question 19
What does the len() function return when called on a string?
A) The memory size of the string B) The number of characters in the string C) The last character of the string
Explanation: The def keyword is used to define functions in Python. It is followed by the function name, parentheses containing parameters, and a colon. This is a fundamental syntax element in Python.
Question 21
What is the output of print(3 * "abc")?
A) abcabcabc B) abc C) aabbcc D) Error
☑Correct Answer: A
Explanation: The * operator with a string and an integer repeats the string. 3 * "abc" creates "abc" repeated 3 times: "abcabcabc". This is string repetition, not multiplication.
Question 22
What is the output of print("Python"[2:5])?
A) Pyt B) tho C) yth D) hon
☑Correct Answer: B