D 335: INTRODUCTION TO
PROGRAMMING IN PYTHON (WGU)
QUESTIONS AND ANSWERS WITH
COMPLETE SOLUTIONS LATEST
UPDATED 2026
Foundations & Data Types
1. Question: What is the result of the expression 17 // 3?
Answer: 5 (The floor division operator // performs division and rounds down to
the nearest whole integer).
2. Question: Which built-in function is used to find the number of elements in a
list or the number of characters in a string?
Answer: len()
3. Question: Is a Python string mutable or immutable?
Answer: Immutable. Once a string is created, its individual characters cannot be
changed or reassigned.
4. Question: What is the output of print("Python"[1:4])?
Answer: yth (Slicing starts at index 1 and goes up to, but does not include, index
4).
5. Question: Which data type is an unordered collection of unique elements?
Answer: Set
Lists, Tuples, and Dictionaries
6. Question: How do you add an item to the very end of an existing list?
Answer: By using the .append() method.
7. Question: What is the main difference between a list and a tuple?
Answer: Lists are mutable (can be changed), while tuples are immutable (cannot
be changed after creation).
, 8. Question: How do you access the value associated with the key 'price' in a
dictionary named car?
Answer: car['price'] or car.get('price').
9. Question: Which method removes and returns the last item from a list?
Answer: .pop()
Control Flow (Branching & Loops)
10. Question: Which keyword is used to provide a specific condition if the
previous if statement was False?
Answer: elif
11. Question: What is the difference between a while loop and a for loop?
Answer: A while loop repeats as long as a condition is True, whereas a for loop
iterates over a sequence (like a list or range).
12. Question: What does the break statement do inside a loop?
Answer: It immediately terminates the loop and moves execution to the first line
of code after the loop.
13. Question: What is the output of list(range(2, 10, 2))?
Answer: [2, 4, 6, 8] (Starts at 2, ends before 10, increments by 2).
Functions & Modules
14. Question: What keyword is used to define a new function in Python?
Answer: def
15. Question: What is a "docstring" in a Python function?
Answer: A string literal placed as the first statement in a function used to
document what the function does.
16. Question: Which statement is used to send a value back to the caller of a
function?
PROGRAMMING IN PYTHON (WGU)
QUESTIONS AND ANSWERS WITH
COMPLETE SOLUTIONS LATEST
UPDATED 2026
Foundations & Data Types
1. Question: What is the result of the expression 17 // 3?
Answer: 5 (The floor division operator // performs division and rounds down to
the nearest whole integer).
2. Question: Which built-in function is used to find the number of elements in a
list or the number of characters in a string?
Answer: len()
3. Question: Is a Python string mutable or immutable?
Answer: Immutable. Once a string is created, its individual characters cannot be
changed or reassigned.
4. Question: What is the output of print("Python"[1:4])?
Answer: yth (Slicing starts at index 1 and goes up to, but does not include, index
4).
5. Question: Which data type is an unordered collection of unique elements?
Answer: Set
Lists, Tuples, and Dictionaries
6. Question: How do you add an item to the very end of an existing list?
Answer: By using the .append() method.
7. Question: What is the main difference between a list and a tuple?
Answer: Lists are mutable (can be changed), while tuples are immutable (cannot
be changed after creation).
, 8. Question: How do you access the value associated with the key 'price' in a
dictionary named car?
Answer: car['price'] or car.get('price').
9. Question: Which method removes and returns the last item from a list?
Answer: .pop()
Control Flow (Branching & Loops)
10. Question: Which keyword is used to provide a specific condition if the
previous if statement was False?
Answer: elif
11. Question: What is the difference between a while loop and a for loop?
Answer: A while loop repeats as long as a condition is True, whereas a for loop
iterates over a sequence (like a list or range).
12. Question: What does the break statement do inside a loop?
Answer: It immediately terminates the loop and moves execution to the first line
of code after the loop.
13. Question: What is the output of list(range(2, 10, 2))?
Answer: [2, 4, 6, 8] (Starts at 2, ends before 10, increments by 2).
Functions & Modules
14. Question: What keyword is used to define a new function in Python?
Answer: def
15. Question: What is a "docstring" in a Python function?
Answer: A string literal placed as the first statement in a function used to
document what the function does.
16. Question: Which statement is used to send a value back to the caller of a
function?