Midterm Exam — Cumulative (Weeks 1–7) · Objectives 1–5
Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Scope: Cumulative — Weeks 1–7, Objectives 1–5 (computing & first programs · variables, types, expressions, I/O & strings · Booleans & conditionals · while & for loops · functions).
Format: 20 items, 100 points (5 points each) · auto-gradable only (multiple-choice, multiple-answer, matching, true/false) with predict-the-output, debugging, and Boolean-result items. AI is not permitted on the midterm.
Points: 100 · Assignment group: Midterm (20% of the course grade) · Window: opens at the start of the module; due 6 days later · allowed attempts: 1.
Human-readable exam with its vetted answer key and one-line feedback. Import-ready Classic QTI 1.2 in
L-midterm-week-08-qti.xml(generated by the validated script — parses with 20 items, every single-answer item exactly one correct). Execution gate: PASS — every keyed output/result was produced by running the code.This is the live exam. Its paired ungraded rehearsal —
O-practice-exam-week-08.md— mirrors this blueprint with fresh variants and shares none of these items.
Blueprint
| # | Type | Concept | Obj |
|---|---|---|---|
| 1 | Multiple choice | Algorithm (computational thinking) | 1 |
| 2 | Multiple choice | Operator precedence (predict output) | 1 |
| 3 | Multiple choice | Debugging — case sensitivity | 1 |
| 4 | Multiple choice | Floor division & modulo (predict) | 2 |
| 5 | Multiple choice | True division gives float (predict) | 2 |
| 6 | Multiple choice | String concatenation (predict) | 2 |
| 7 | Multiple choice | String slicing (predict) | 2 |
| 8 | Multiple choice | input() return type | 2 |
| 9 | Multiple choice | Boolean logic (predict) | 3 |
| 10 | Multiple choice | if/elif/else — which branch (predict) | 3 |
| 11 | True / False | = vs == | 3 |
| 12 | Matching | Boolean expression results | 3 |
| 13 | Multiple choice | while accumulator (predict) | 4 |
| 14 | Multiple choice | range exclusive stop (predict) | 4 |
| 15 | Multiple choice | range with step (predict) | 4 |
| 16 | Multiple choice | for accumulator (predict) | 4 |
| 17 | Multiple choice | Debugging — infinite loop | 4 |
| 18 | Multiple choice | Function return (predict) | 5 |
| 19 | Multiple choice | return vs print → None (predict) | 5 |
| 20 | Multiple choice | Local scope | 5 |
Objective totals: Obj 1 = 3 · Obj 2 = 5 · Obj 3 = 4 · Obj 4 = 5 · Obj 5 = 3 → 20 items, 100 points. The midterm does not reach collections, files, algorithms, recursion, or OOP (Weeks 9–15), which are on the cumulative final.
Questions, key, and feedback
Q1 (Multiple choice). An algorithm is best described as —
- a programming language
- a step-by-step plan for solving a problem ✅
- an error message
- a type of loop
Feedback: An algorithm is the step-by-step plan; coding writes it in a language like Python.
Q2 (Multiple choice). What does this print?
print(10 - 2 * 3)
- 24
- 4 ✅
- 6
- 30
Feedback: Multiplication before subtraction: 2*3=6, then 10-6=4. (Run-verified.)
Q3 (Multiple choice). This line crashes. Why?
Print("hi")
- missing a semicolon
- Python is case-sensitive; use lowercase print ✅
- the quotes are wrong
- nothing is wrong
Feedback: Only lowercase print is the built-in; Print raises NameError. (Run-verified.)
Q4 (Multiple choice). What does this print?
print(7 // 2, 7 % 2)
- 3 1 ✅
- 3.5 1
- 1 3
- 3 0
Feedback: // is floor division (3); % is the remainder (1). (Run-verified.)
Q5 (Multiple choice). What does this print?
print(10 / 2)
- 5
- 5.0 ✅
- 2
- 0.2
Feedback: In Python, / always returns a float, so 10 / 2 is 5.0, not 5. (Run-verified.)
Q6 (Multiple choice). What does this print?
print("ab" + "cd")
- abcd ✅
- ab cd
- cdab
- an error
Feedback: + joins strings (concatenation): 'ab'+'cd' is 'abcd'. (Run-verified.)
Q7 (Multiple choice). What does this print?
print("PYTHON"[1:4])
- PYT
- YTH ✅
- YTHO
- YT
Feedback: Slice [1:4] takes indices 1,2,3 (stop is exclusive): Y, T, H. (Run-verified.)
Q8 (Multiple choice). What type does input() always return?
- int
- float
- str (a string) ✅
- bool
Feedback: input() always returns a string; convert with int(...) for math.
Q9 (Multiple choice). What does this print?
print(True and not False)
- True ✅
- False
- None
- an error
Feedback: not False is True; True and True is True. (Run-verified.)
Q10 (Multiple choice). What does this print?
score = 75
if score >= 90:
print('A')
elif score >= 70:
print('C')
else:
print('F')
- A
- C ✅
- F
- nothing
Feedback: 75 is not >= 90 but is >= 70, so the elif runs: C. (Run-verified.)
Q11 (True / False). In Python, a single = compares two values for equality.
- True
- False ✅
Feedback: False. = assigns; == compares. Using = in an if condition is a SyntaxError.
Q12 (Matching). Match each expression to its value.
| Left | Correct match |
|---|---|
| 3 > 2 | True |
| 2 == 3 | False |
| 5 != 5 | False |
| not False | True |
Feedback: Comparisons evaluate to True or False; not flips the value. (All run-verified.)
Q13 (Multiple choice). What does this print?
total = 0
i = 1
while i <= 4:
total = total + i
i = i + 1
print(total)
- 4
- 10 ✅
- 6
- 16
Feedback: It adds 1+2+3+4 = 10. (Run-verified.)
Q14 (Multiple choice). What does this print?
print(list(range(1, 5)))
- [1, 2, 3, 4, 5]
- [1, 2, 3, 4] ✅
- [0, 1, 2, 3, 4]
- [1, 5]
Feedback: range(1,5) is 1,2,3,4 — the stop value 5 is excluded. (Run-verified.)
Q15 (Multiple choice). What does this print?
print(list(range(0, 10, 2)))
- [0, 2, 4, 6, 8] ✅
- [0, 2, 4, 6, 8, 10]
- [2, 4, 6, 8]
- [0, 1, 2, ..., 10]
Feedback: Start 0, step 2, stop 10 (exclusive): 0,2,4,6,8. (Run-verified.)
Q16 (Multiple choice). What does this print?
total = 0
for n in range(5):
total = total + n
print(total)
- 15
- 10 ✅
- 5
- 0
Feedback: range(5) is 0,1,2,3,4; their sum is 10. (Run-verified.)
Q17 (Multiple choice). Why does this loop run forever?
i = 0
while i < 3:
print(i)
- i is never increased, so i < 3 stays true ✅
- print is misspelled
- the range is wrong
- it does not run forever
Feedback: There's no i = i + 1, so i stays 0 and the condition never becomes false. Add the increment.
Q18 (Multiple choice). What does this print?
def add(a, b):
return a + b
print(add(3, 4))
- 7 ✅
- 34
- None
- ab
Feedback: add returns 3+4 = 7. (Run-verified.)
Q19 (Multiple choice). What does this print?
def greet(name):
print('Hi ' + name)
result = greet('Sam')
print(result)
- Hi Sam then Hi Sam
- Hi Sam then None ✅
- Hi Sam then Sam
- None then Hi Sam
Feedback: greet prints 'Hi Sam' but has no return, so result is None. (Run-verified.)
Q20 (Multiple choice). What happens here?
def f():
x = 5
f()
print(x)
- prints 5
- prints None
- NameError: x is not defined (x is local to f) ✅
- prints 0
Feedback: x is local to f and doesn't exist outside it, so print(x) raises NameError. (Run-verified.)
Answer key (quick reference)
| Q | Answer | Q | Answer |
|---|---|---|---|
| 1 | B | 11 | False |
| 2 | B | 12 | 1-to-1 (see above) |
| 3 | B | 13 | B |
| 4 | A | 14 | B |
| 5 | B | 15 | A |
| 6 | A | 16 | B |
| 7 | B | 17 | A |
| 8 | C | 18 | A |
| 9 | A | 19 | B |
| 10 | B | 20 | C |
Quality gate (self-checked)
- Structure: 20 items, 5 points each, 100 points; coverage Obj 1 = 3 · Obj 2 = 5 · Obj 3 = 4 · Obj 4 = 5 · Obj 5 = 3.
- Execution gate: PASS — all 16 predict-the-output / behavior items were re-run in Python and their keyed outputs confirmed (e.g. Q2 4; Q4 3 1; Q5 5.0; Q7 YTH; Q10 C; Q13 10; Q14 [1, 2, 3, 4]; Q18 7; Q19 None; Q20 NameError).
- Single-answer integrity: every multiple-choice and true/false item has exactly one correct option; matching items pair one-to-one; multiple-answer items key the exact set.
- Integrity vs. the practice exam: 0 items are shared with
O-practice-exam-week-08.md(verified by full stem comparison — same concepts, different programs and values).
Canvas placement block
canvas_object = Quizzes::Quiz
title = "Midterm Exam — Cumulative (Weeks 1–7)"
assignment_group = "Midterm"
points_possible = 100
grading_type = points
available_from_offset_days = 0
due_offset_days = 6
published = true
allowed_attempts = 1
shuffle_answers = true
ai_permitted = false
provenance = "~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com"
L-midterm-week-08-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