Docsity

WGU E010 Foundations of Programming (Python) – Comprehensive Objective Assessment Question, Exams of Nursing

Toggle sidebar
bg1
1
WGU E010 Foundations of Programming (Python)
– Comprehensive Objective Assessment Question
Bank 220 Multiple-Choice Questions with
Verified Answers and Detailed Rationales Aligned
with WGU E010 (D335) Exam Objectives –
Updated for 2026
SECTION 1: VARIABLES, DATA TYPES, AND TYPE CONVERSION (Questions 1–25)
1. Which of the following is a valid variable name in Python?
A. 2ndPlace
B. my-variable
C. my_variable
D. class
☑VERIFIED ANSWER: C
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 Question and more Exams Nursing in PDF only on Docsity!

WGU E010 Foundations of Programming (Python)

– Comprehensive Objective Assessment Question

Bank 220 Multiple-Choice Questions with

Verified Answers and Detailed Rationales Aligned

with WGU E010 (D335) Exam Objectives –

Updated for 2026

SECTION 1: VARIABLES, DATA TYPES, AND TYPE CONVERSION (Questions 1–25)

1. Which of the following is a valid variable name in Python? A. 2ndPlace B. my-variable C. my_variable D. class ☑VERIFIED ANSWER: C

Rationale: Python variable names cannot start with a digit (eliminating 2ndPlace), cannot contain hyphens (eliminating my-variable), and cannot be reserved keywords like class (eliminating class). Underscores are allowed and commonly used, so my_variable is valid.

2. What is the output of the following code? python x = 5 y = 10 print(x + y) A. 510 B. 15

☑VERIFIED ANSWER: B

Rationale: In Python, 0 is considered False when converted to a Boolean. Any non- zero number (positive or negative) is considered True.

4. What is the output of bool("") (empty string)? A. True B. False C. "" D. Error ☑VERIFIED ANSWER: B Rationale: An empty string is considered False when converted to a Boolean. Non-empty strings are considered True.

5. Which of the following is a Boolean value in Python? A. "True" B. true C. True D. 1 ☑VERIFIED ANSWER: C Rationale: Python's Boolean values are True and False (capitalized). "True" is a string, true is not a valid keyword (case matters), and 1 is an integer that evaluates to True in a Boolean context but is not itself a Boolean. 6. What is the output of the following code? python

print(2 ** 3) A. 6 B. 8 C. 9 D. 5 ☑VERIFIED ANSWER: B Rationale: The ** operator performs exponentiation. 2 ** 3 means 2 raised to the power of 3, which equals 8.

8. What is the output of the following code? python print(10 // 3) A. 3. B. 3

C. 4

D. 3.

☑VERIFIED ANSWER: B

Rationale: The // operator performs floor division (integer division), returning the quotient without the remainder. 10 // 3 equals 3.

9. What is the output of the following code? python print(10 % 3) A. 3 B. 1 C. 0

CoRRECt ANSWER: 10 C Rationale: Python uses the = operator for variable assignment. age == 25 is a comparison, := is the walrus operator (assignment expression) used in specific contexts, and int age = 25 is Java/C++ syntax.

11. What is the output of the following code? python x = "5" y = 2 print(x * y) A. 10 B. 7 C. "55"

CoRRECt ANSWER: 11 D. Error C Rationale: Multiplying a string by an integer repeats the string. "5" * 2 results in "55". If numeric addition was intended, the string would need to be converted to an integer first.

12. What is the output of the following code? python print(int(3.9)) A. 3. B. 3 C. 4 D. Error B

14. What is the output of the following code? python print(str(100)) A. 100 B. "100" C. '100' D. Both B and C ☑VERIFIED ANSWER: D Rationale: The str() function converts a value to a string. str(100) returns "100". In Python, single and double quotes are equivalent for strings.

15. What is the output of the following code? python print(type(3.14)) A. int B. float C. double D. str ☑VERIFIED ANSWER: B Rationale: 3.14 is a floating-point number. The type() function returns float as the data type. 16. What is the output of the following code?

17. Which of the following is NOT a valid data type in Python? A. int B. float C. double D. str ☑VERIFIED ANSWER: C Rationale: Python does not have a double data type. Floating-point numbers in Python are of type float. 18. What is the output of the following code? python x = True

print(type(x)) A. bool B. Boolean C. True D. int ☑VERIFIED ANSWER: A Rationale: True is a Boolean value in Python. The type() function returns bool.

19. What is the output of the following code? python print(5 + 3 * 2) A. 16

C. 13

D. 10

☑VERIFIED ANSWER: A

Rationale: Parentheses override operator precedence. 5 + 3 = 8, then 8 * 2 = 16.

21. Which of the following is NOT a valid way to create a string in Python? A. 'Hello' B. "Hello" C. """Hello""" D. (Hello)

CoRRECt ANSWER: 20 D Rationale: Strings in Python can be created with single quotes ('Hello'), double quotes ("Hello"), or triple quotes ("""Hello"""). (Hello) is not a string—it would be interpreted as a tuple or cause a NameError.

22. What is the output of the following code? python x = 5 y = 2 print(x ** y) A. 7 B. 10 C. 25