WGU D335 INTRODUCTION TO PROGRAMMING IN PYTHON
OBJECTIVE ASSESSMENT – WESTERN GOVERNORS ] ACTUAL
QUESTIONS AND CORRECT ANSWERS (VERIFIED ANSWERS)
PLUS RATIONALES 2026 Q&A | INSTANT DOWNLOAD PDF.
Core Domains
Python Fundamentals and Syntax
Variables, Data Types, and Operators
Control Structures: Conditionals and Loops
Functions, Parameters, and Return Values
Strings, Lists, Tuples, and Dictionaries
File Input/Output and Exception Handling
Object-Oriented Programming: Classes and Objects
Standard Library Modules and Documentation
Introduction
This comprehensive objective assessment evaluates the student’s proficiency in
the foundational concepts of Python programming as covered in WGU D335. The
examination tests the ability to write, debug, and analyze Python code using core
language constructs including variables, data types, operators, control flow,
functions, built-in data structures, file operations, and introductory object-
oriented programming. Questions are presented as multiple-choice and code-
interpretation items that mirror real-world scripting tasks. Emphasis is placed on
practical application of Python syntax, logical problem-solving, and best practices
in writing clean and efficient code. Success demonstrates readiness to advance
into intermediate programming courses and apply Python skills to academic and
entry-level professional projects.
SECTION ONE: QUESTIONS 1–100
Question 1
What is the output of the following Python code?
python
x=5
,y=2
print(x // y)
A. 2.5
B. 2
C. 2.0
D. 1
B. 2
RATIONALE: The // operator performs floor division, which divides and
truncates the decimal part, returning an integer. 5 // 2 equals 2. Regular
division / would return 2.5. % is modulo. So the result is 2.
Question 2
Which of the following correctly creates a list in Python?
A. list = {1, 2, 3}
B. list = (1, 2, 3)
C. list = [1, 2, 3]
D. list = "1, 2, 3"
C. list = [1, 2, 3]
RATIONALE: Lists are defined using square brackets []. Curly braces {} create
a set or dictionary, parentheses () create a tuple, and quotes create a string. So C
is correct.
Question 3
In Python, which keyword is used to define a function?
A. function
B. def
C. define
D. func
B. def
RATIONALE: Functions are defined using the def keyword, followed by the
function name and parentheses. For example: def my_func():. The other terms
are not valid Python keywords for function definition.
Question 4
What is the value of result after executing the following code?
,python
x = 10
if x > 5:
result = "Greater"
else:
result = "Less or Equal"
A. "Greater"
B. "Less or Equal"
C. None
D. Error
A. "Greater"
RATIONALE: x is 10, which is greater than 5, so the if condition is true,
and result is assigned "Greater". The else block is skipped.
Question 5
Which of the following is an immutable data type in Python?
A. List
B. Dictionary
C. Set
D. Tuple
D. Tuple
RATIONALE: Tuples are immutable, meaning their elements cannot be
changed after creation. Lists, dictionaries, and sets are mutable.
Question 6
What will len("Hello World") return?
A. 10
B. 11
C. 12
D. 5
B. 11
RATIONALE: The len() function counts the number of characters in the string,
, including spaces. "Hello World" has 11 characters (5 for Hello, 1 space, 5 for
World).
Question 7
Which operator is used for exponentiation in Python?
A. ^
B. **
C. *
D. %
B. **
RATIONALE: ** raises a number to a power (e.g., 2**3 = 8). ^ is the bitwise
XOR operator, * multiplication, % modulo.
Question 8
What does the range(5) function generate?
A. Numbers 1 to 5
B. Numbers 0 to 5
C. Numbers 0 to 4
D. Numbers 1 to 4
C. Numbers 0 to 4
RATIONALE: range(5) generates a sequence from 0 up to (but not including)
5, i.e., 0, 1, 2, 3, 4. range(1,5) would produce 1 to 4.
Question 9
How do you access the value associated with the key "name" in a
dictionary person = {"name": "Alice", "age": 30}?
A. person["Alice"]
B. person.name
C. person["name"]
D. person(name)
C. person["name"]
RATIONALE: Dictionary values are accessed using square brackets with the
key as a string. person["name"] returns "Alice". Dot notation is not used for
dictionaries; that's for objects.
OBJECTIVE ASSESSMENT – WESTERN GOVERNORS ] ACTUAL
QUESTIONS AND CORRECT ANSWERS (VERIFIED ANSWERS)
PLUS RATIONALES 2026 Q&A | INSTANT DOWNLOAD PDF.
Core Domains
Python Fundamentals and Syntax
Variables, Data Types, and Operators
Control Structures: Conditionals and Loops
Functions, Parameters, and Return Values
Strings, Lists, Tuples, and Dictionaries
File Input/Output and Exception Handling
Object-Oriented Programming: Classes and Objects
Standard Library Modules and Documentation
Introduction
This comprehensive objective assessment evaluates the student’s proficiency in
the foundational concepts of Python programming as covered in WGU D335. The
examination tests the ability to write, debug, and analyze Python code using core
language constructs including variables, data types, operators, control flow,
functions, built-in data structures, file operations, and introductory object-
oriented programming. Questions are presented as multiple-choice and code-
interpretation items that mirror real-world scripting tasks. Emphasis is placed on
practical application of Python syntax, logical problem-solving, and best practices
in writing clean and efficient code. Success demonstrates readiness to advance
into intermediate programming courses and apply Python skills to academic and
entry-level professional projects.
SECTION ONE: QUESTIONS 1–100
Question 1
What is the output of the following Python code?
python
x=5
,y=2
print(x // y)
A. 2.5
B. 2
C. 2.0
D. 1
B. 2
RATIONALE: The // operator performs floor division, which divides and
truncates the decimal part, returning an integer. 5 // 2 equals 2. Regular
division / would return 2.5. % is modulo. So the result is 2.
Question 2
Which of the following correctly creates a list in Python?
A. list = {1, 2, 3}
B. list = (1, 2, 3)
C. list = [1, 2, 3]
D. list = "1, 2, 3"
C. list = [1, 2, 3]
RATIONALE: Lists are defined using square brackets []. Curly braces {} create
a set or dictionary, parentheses () create a tuple, and quotes create a string. So C
is correct.
Question 3
In Python, which keyword is used to define a function?
A. function
B. def
C. define
D. func
B. def
RATIONALE: Functions are defined using the def keyword, followed by the
function name and parentheses. For example: def my_func():. The other terms
are not valid Python keywords for function definition.
Question 4
What is the value of result after executing the following code?
,python
x = 10
if x > 5:
result = "Greater"
else:
result = "Less or Equal"
A. "Greater"
B. "Less or Equal"
C. None
D. Error
A. "Greater"
RATIONALE: x is 10, which is greater than 5, so the if condition is true,
and result is assigned "Greater". The else block is skipped.
Question 5
Which of the following is an immutable data type in Python?
A. List
B. Dictionary
C. Set
D. Tuple
D. Tuple
RATIONALE: Tuples are immutable, meaning their elements cannot be
changed after creation. Lists, dictionaries, and sets are mutable.
Question 6
What will len("Hello World") return?
A. 10
B. 11
C. 12
D. 5
B. 11
RATIONALE: The len() function counts the number of characters in the string,
, including spaces. "Hello World" has 11 characters (5 for Hello, 1 space, 5 for
World).
Question 7
Which operator is used for exponentiation in Python?
A. ^
B. **
C. *
D. %
B. **
RATIONALE: ** raises a number to a power (e.g., 2**3 = 8). ^ is the bitwise
XOR operator, * multiplication, % modulo.
Question 8
What does the range(5) function generate?
A. Numbers 1 to 5
B. Numbers 0 to 5
C. Numbers 0 to 4
D. Numbers 1 to 4
C. Numbers 0 to 4
RATIONALE: range(5) generates a sequence from 0 up to (but not including)
5, i.e., 0, 1, 2, 3, 4. range(1,5) would produce 1 to 4.
Question 9
How do you access the value associated with the key "name" in a
dictionary person = {"name": "Alice", "age": 30}?
A. person["Alice"]
B. person.name
C. person["name"]
D. person(name)
C. person["name"]
RATIONALE: Dictionary values are accessed using square brackets with the
key as a string. person["name"] returns "Alice". Dot notation is not used for
dictionaries; that's for objects.