Docsity

WGU E010 Foundations of Programming (Python): Comprehensive Objective Assessment, Exams of Computer Science

Toggle sidebar
bg1
1
WGU E010 Foundations of Programming (Python):
Comprehensive Objective Assessment Practice Exam
180 Multiple-Choice Questions with Verified Answers and
Detailed Explanations 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
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
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download WGU E010 Foundations of Programming (Python): Comprehensive Objective Assessment and more Exams Computer Science in PDF only on Docsity!

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

C) 4

D) 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()

B) []

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