Week 9 — Quiz (auto-graded) · Lists
Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Objective tested: Objective 6 — creating, indexing & slicing lists; mutation & list methods; iterating; aliasing vs. copying; debugging.
Points: 10 (1 each) · Assignment group: Quizzes (10% of grade) · Due: end of Module 9.
This is the human-readable quiz with its vetted answer key and feedback. The import-ready Classic QTI is in
F-quiz-week-09-qti.xml(generated by the shared validated script — parses with 10 items, every single-answer item exactly one correct). Execution gate: PASS — every "what does this print?" key below was produced by actually running the code in Python, not hand-traced (the mutate-while-iterating key in Q7 is one most people get wrong by hand; we ran it). The Canvas placement block is at the bottom of this file.
Blueprint
| # | Type | Concept | Objective |
|---|---|---|---|
| 1 | Multiple choice | What a list is (ordered, mutable) | 6 |
| 2 | Multiple choice | Predict the output — append (method effect) |
6 |
| 3 | Multiple choice | Predict the output — slicing (exclusive stop) | 6 |
| 4 | Multiple choice | Predict the output — aliasing (b = a) |
6 |
| 5 | Multiple choice | Predict the output — list contents after insert + pop |
6 |
| 6 | Multiple answer | True statements about list methods (append/pop/len vs. sort/remove) |
6 |
| 7 | Multiple choice | Debugging — mutate-while-iterating (what it ACTUALLY prints) | 6 |
| 8 | Multiple choice | Reading an error — IndexError (reach past the end) |
6 |
| 9 | True / False | sort() returns None, not the sorted list |
6 |
| 10 | Matching | List operation → effect (append/insert/pop/b = a[:]) |
6 |
No trick questions; distractors are plausible mis-traces (off-by-one indexing, inclusive-stop slicing, treating b = a as a copy, remove-by-index confusion, expecting a "clean" mutate-while-iterating result).
Questions, key, and feedback
Q1 (MC). Which statement about Python lists is TRUE?
- A. A list can hold only numbers
- B. A list is an ordered collection that can be changed after it is created ✅
- C. Once created, a list can never be changed
- D. A list's items have no order, so indexing is random
Feedback: A list is ordered (items have positions you reach by index) and mutable (you can change it after creating it — nums[0] = 9, append, pop, etc.). It can hold mixed types, not only numbers. (C describes strings, which are immutable; D is false — lists keep their order.)
Q2 (MC). What does this program print?
nums = [1, 2, 3]
nums.append(4)
print(nums)
- A.
[1, 2, 3] - B.
[4, 1, 2, 3] - C.
[1, 2, 3, 4]✅ - D.
[1, 2, 3, [4]]
Feedback:append(x)addsxto the end of the list, so the list becomes[1, 2, 3, 4]. (B would beinsert(0, 4); D would happen if you appended a list[4]. Run-verified:[1, 2, 3, 4].)
Q3 (MC). What does this program print?
letters = ["a", "b", "c", "d", "e"]
print(letters[1:4])
- A.
['b', 'c', 'd']✅ - B.
['a', 'b', 'c', 'd'] - C.
['b', 'c', 'd', 'e'] - D.
['c', 'd']
Feedback: A slice[1:4]includes indexes 1, 2, and 3 — the stop (4) is excluded — so you get['b', 'c', 'd']. This is the same exclusive-stop rule as string slicing. (B starts too early; C includes index 4. Run-verified:['b', 'c', 'd'].)
Q4 (MC). What does this program print? (Note it prints a, not b.)
a = [1, 2]
b = a
b.append(3)
print(a)
- A.
[1, 2] - B.
[1, 2, 3]✅ - C.
[3, 1, 2] - D. an error
Feedback:b = adoes not copy the list — it makesba second name for the same list (aliasing). Appending throughbchanges the one and only list, soashows[1, 2, 3]too. To get an independent copy, useb = a[:]. (A is the most common wrong answer — the assumption thatb = acopies. Run-verified:[1, 2, 3].)
Q5 (MC). What does this program print?
data = [2, 4, 6, 8]
data.insert(0, 0)
data.pop(2)
print(data)
- A.
[0, 2, 6, 8]✅ - B.
[2, 4, 6, 8] - C.
[0, 2, 4, 8] - D.
[0, 4, 6, 8]
Feedback:insert(0, 0)puts0at the front →[0, 2, 4, 6, 8]. Thenpop(2)removes the item at index 2 (the4) →[0, 2, 6, 8]. (C removes the wrong index; D pops index 1. Run-verified:[0, 2, 6, 8].)
Q6 (Multiple answer — select all that apply). Which statements are TRUE about Python lists?
- A. append(x) adds x to the end of the list ✅
- B. sort() returns a new sorted list and leaves the original unchanged
- C. pop() removes and returns the last item ✅
- D. len(nums) gives the number of items in the list ✅
- E. remove(2) deletes the item at index 2
Feedback: append adds to the end (A), pop() removes and returns the last item (C), and len counts items (D). B is false — sort() sorts the list in place and returns None. E is false — remove(2) deletes the first item equal to the value 2, not the item at index 2 (use pop(2) for that).
Q7 (MC). This loop is meant to remove every 4 from the list. What does it ACTUALLY print?
nums = [4, 4, 5]
for n in nums:
if n == 4:
nums.remove(4)
print(nums)
- A.
[5] - B.
[4, 5]✅ - C.
[4, 4, 5] - D. an error
Feedback: This is the mutate-while-iterating bug. Removing the first4shifts everything left, so the loop skips the second4— leaving[4, 5]. It does not crash; it silently gives the wrong answer. The fix is to loop over a copy (for n in nums[:]:) or build a new list. (A is what most people expect; the loop can't reach the shifted item. Run-verified:[4, 5].)
Q8 (MC). You run this program. What happens?
nums = [10, 20, 30]
print(nums[3])
- A. It prints
30 - B. It prints
0 - C. It raises an
IndexError(list index out of range) ✅ - D. It prints an empty list
[]
Feedback: The list has three items at indexes 0, 1, 2 — there is no index 3, so Python raisesIndexError: list index out of range. This is the classic off-by-one error. The last item isnums[2]ornums[-1]. (Run-verified: it raisesIndexError.)
Q9 (True / False). "After result = nums.sort(), the variable result holds the sorted list."
- True
- False ✅
Feedback: False. sort() reorders the list in place and returns None, so result is None — even though nums itself ends up sorted. Writing nums = nums.sort() is a common bug that throws the list away. Just call nums.sort() on its own line. (Run-verified: result is None.)
Q10 (Matching). Match each list operation to its effect.
| Operation | Correct effect |
|---|---|
| append(x) | Adds x to the end of the list |
| insert(i, x) | Puts x at index i, shifting later items right |
| pop() | Removes and returns the last item |
| b = a[:] | Makes an independent copy of the list |
Feedback: append adds to the end; insert(i, x) places x at a specific index and shifts the rest right; pop() removes and returns the last item; and b = a[:] makes a separate copy (unlike b = a, which aliases).
Answer key (quick reference)
| Q | Answer |
|---|---|
| 1 | B |
| 2 | C ([1, 2, 3, 4]) |
| 3 | A (['b', 'c', 'd']) |
| 4 | B ([1, 2, 3]) |
| 5 | A ([0, 2, 6, 8]) |
| 6 | A, C, D |
| 7 | B ([4, 5]) |
| 8 | C (IndexError) |
| 9 | False |
| 10 | append→end / insert→at index i / pop→removes & returns last / b=a[:]→independent copy |
Quality gate (self-checked): each single-answer item has exactly one correct option; the multiple-answer item keys A, C, D (and requires B and E unselected); the matching item pairs four operations to four distinct effects. Execution gate: PASS — the keys for the predict-the-output items (Q2 [1,2,3,4]; Q3 ['b','c','d']; Q4 [1,2,3]; Q5 [0,2,6,8]; Q7 [4,5]), the error item (Q8 IndexError), and the return-value item (Q9 None) were each produced by running the code in Python, not hand-traced. Distractors are plausible mis-traces (Q3 inclusive stop; Q4 treating b=a as a copy; Q7 the "clean" result [5]; Q6 sort returning a list / remove by index).
Item-bank entries (for variants + the final)
All ten items are tagged course=CSCI1101 · week=9 · objective=6 · topic=lists and deposited in Item Bank: Week 9 — Lists. The final (Week 16) and the per-term variant updates draw fresh items from this bank. (Tags: q1 list-mutable, q2 append, q3 slice-exclusive, q4 aliasing, q5 insert-pop, q6 method-truths, q7 mutate-while-iterating, q8 indexerror, q9 sort-returns-none, q10 op-effect-match.)
Canvas placement block
canvas_object = Quizzes::Quiz
title = "Week 9 Quiz — Lists"
assignment_group = "Quizzes"
points_possible = 10
grading_type = points
due_offset_days = 6 # 6 days after module start
published = true
shuffle_answers = true
ai_permitted = false # AI is not permitted on quizzes
provenance = "~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com"
F-quiz-week-09-qti.xml) ships inside the course's .imscc package — it lands in the Canvas gradebook on import.~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com