Page 1 of 88
WGU D335 — INTRODUCTION TO PROGRAMMING IN PYTHON:
OBJECTIVE ASSESSMENT EXAM COMPREHENSIVE QUESTIONS AND
CORRECT ANSWERS LATEST EDITION 2026
WGU D335 — Introduction to Programming in Python: Objective Assessment — Questions
with Rationales
Summarized 10-Point Exam Coverage
Based on the official WGU D335 (NKO2) Objective Assessment weighting:
1. Python Fundamentals & Syntax (25%) — variables, data types, operators, input/output,
type conversion, comments, and basic program structure (IPO model).
2. Data Types & Structures (25%) — lists, tuples, dictionaries, sets, strings, indexing,
slicing, mutability, and built-in methods.
3. Control Flow & Loops (20%) — if/elif/else, for loops, while loops, range(), break,
continue, nested loops, and logical operators.
4. Functions & Modules (15%) — def, parameters, default arguments, return values, scope,
lambda, import, and recursion.
5. File I/O & Exception Handling (10%) — open(), read(), write(), with statement,
try/except/finally, and common exception types.
6. Problem Solving & Algorithms (5%) — IPO thinking, tracing code, debugging logic
errors, and algorithmic sequencing.
1|Page
,Page 2 of 88
SECTION 1: PYTHON FUNDAMENTALS & SYNTAX (Questions 1–60)
Q1. What is the correct way to output "Hello World" to the console in Python?
A. console.log("Hello World")
B. printf("Hello World")
C. print("Hello World")
D. echo "Hello World"
Correct Answer: C
Rationale: The built-in print() function is used to output text to the console in Python.
console.log() is JavaScript, printf() is C, and echo is PHP/Shell.
Q2. A program consists of which three basic instruction types?
A. Read, Write, Execute
B. Input, Process, Output
C. Compile, Link, Run
D. Define, Call, Return
Correct Answer: B
Rationale: Every program follows the IPO model: it takes input, processes that data, and
produces output.
Q3. What is a variable in Python?
A. A fixed value that cannot change
B. A named reference to a value stored in memory
C. A type of loop structure
D. A function that prints output
2|Page
,Page 3 of 88
Correct Answer: B
Rationale: A variable is a named item used to hold a value. It acts as a reference or label that
points to an object in memory. Variables can be reassigned to different values.
Q4. What is an algorithm?
A. A type of Python data structure
B. A sequence of instructions that solves a problem
C. A built-in Python function
D. An error in program execution
Correct Answer: B
Rationale: An algorithm is a step-by-step sequence of instructions designed to solve a specific
problem or accomplish a task.
Q5. What does the print() function do in Python?
A. Reads input from the user
B. Displays output to the screen and starts a new line
C. Opens a file for reading
D. Converts a value to a string
Correct Answer: B
Rationale: The print() function outputs text or variable values to the console. By default, it adds
a newline character at the end.
Q6. How do you denote a comment in Python?
A. // comment
B. /* comment */
3|Page
, Page 4 of 88
C. # comment or """multi-line comment"""
D. <!-- comment -->
Correct Answer: C
Rationale: Single-line comments begin with #. Multi-line comments can be enclosed in triple
quotes. Comments are ignored by the interpreter.
Q7. What is the purpose of the input() function?
A. To display output to the screen
B. To get text input from the user
C. To convert data types
D. To open a file
Correct Answer: B
Rationale: The input() function reads a line of text from the user and returns it as a string. It can
optionally display a prompt string.
Q8. What does the type() function return?
A. The size of a variable in memory
B. The data type of a variable or value
C. The value of a variable
D. The memory address of a variable
Correct Answer: B
Rationale: The type() function returns the data type of a variable or value. For example,
type(3.14) returns <class 'float'>.
Q9. Which of the following is a valid variable name in Python?
4|Page
WGU D335 — INTRODUCTION TO PROGRAMMING IN PYTHON:
OBJECTIVE ASSESSMENT EXAM COMPREHENSIVE QUESTIONS AND
CORRECT ANSWERS LATEST EDITION 2026
WGU D335 — Introduction to Programming in Python: Objective Assessment — Questions
with Rationales
Summarized 10-Point Exam Coverage
Based on the official WGU D335 (NKO2) Objective Assessment weighting:
1. Python Fundamentals & Syntax (25%) — variables, data types, operators, input/output,
type conversion, comments, and basic program structure (IPO model).
2. Data Types & Structures (25%) — lists, tuples, dictionaries, sets, strings, indexing,
slicing, mutability, and built-in methods.
3. Control Flow & Loops (20%) — if/elif/else, for loops, while loops, range(), break,
continue, nested loops, and logical operators.
4. Functions & Modules (15%) — def, parameters, default arguments, return values, scope,
lambda, import, and recursion.
5. File I/O & Exception Handling (10%) — open(), read(), write(), with statement,
try/except/finally, and common exception types.
6. Problem Solving & Algorithms (5%) — IPO thinking, tracing code, debugging logic
errors, and algorithmic sequencing.
1|Page
,Page 2 of 88
SECTION 1: PYTHON FUNDAMENTALS & SYNTAX (Questions 1–60)
Q1. What is the correct way to output "Hello World" to the console in Python?
A. console.log("Hello World")
B. printf("Hello World")
C. print("Hello World")
D. echo "Hello World"
Correct Answer: C
Rationale: The built-in print() function is used to output text to the console in Python.
console.log() is JavaScript, printf() is C, and echo is PHP/Shell.
Q2. A program consists of which three basic instruction types?
A. Read, Write, Execute
B. Input, Process, Output
C. Compile, Link, Run
D. Define, Call, Return
Correct Answer: B
Rationale: Every program follows the IPO model: it takes input, processes that data, and
produces output.
Q3. What is a variable in Python?
A. A fixed value that cannot change
B. A named reference to a value stored in memory
C. A type of loop structure
D. A function that prints output
2|Page
,Page 3 of 88
Correct Answer: B
Rationale: A variable is a named item used to hold a value. It acts as a reference or label that
points to an object in memory. Variables can be reassigned to different values.
Q4. What is an algorithm?
A. A type of Python data structure
B. A sequence of instructions that solves a problem
C. A built-in Python function
D. An error in program execution
Correct Answer: B
Rationale: An algorithm is a step-by-step sequence of instructions designed to solve a specific
problem or accomplish a task.
Q5. What does the print() function do in Python?
A. Reads input from the user
B. Displays output to the screen and starts a new line
C. Opens a file for reading
D. Converts a value to a string
Correct Answer: B
Rationale: The print() function outputs text or variable values to the console. By default, it adds
a newline character at the end.
Q6. How do you denote a comment in Python?
A. // comment
B. /* comment */
3|Page
, Page 4 of 88
C. # comment or """multi-line comment"""
D. <!-- comment -->
Correct Answer: C
Rationale: Single-line comments begin with #. Multi-line comments can be enclosed in triple
quotes. Comments are ignored by the interpreter.
Q7. What is the purpose of the input() function?
A. To display output to the screen
B. To get text input from the user
C. To convert data types
D. To open a file
Correct Answer: B
Rationale: The input() function reads a line of text from the user and returns it as a string. It can
optionally display a prompt string.
Q8. What does the type() function return?
A. The size of a variable in memory
B. The data type of a variable or value
C. The value of a variable
D. The memory address of a variable
Correct Answer: B
Rationale: The type() function returns the data type of a variable or value. For example,
type(3.14) returns <class 'float'>.
Q9. Which of the following is a valid variable name in Python?
4|Page