← Introduction to Computer Science outline
Week 8 · Study guide
Week 8 — Midterm Study Guide (Cumulative, Weeks 1–7)
Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Use this with: the Review Deck (E), the Exam-Prep Tutorial (N), and the Practice Midterm (O). The Midterm covers Objectives 1–5.
For every code box below: predict the output, then run it in the online editor. The midterm is mostly predict-the-output and debugging.
What's covered (and the point split)
| Objective | Topic | Weeks | ~Items |
|---|---|---|---|
| 1 | Computing, print, tracing, errors |
1 | 3 |
| 2 | Variables, types, expressions, I/O, strings | 2–3 | 5 |
| 3 | Booleans & conditionals | 4 | 4 |
| 4 | while & for loops (incl. nesting) |
5–6 | 5 |
| 5 | Functions (params, return, scope) | 7 | 3 |
Objective 1 — Computing, print, errors
- A program runs top to bottom; the computer does exactly what you wrote.
- Precedence:
*,/,//,%before+,-.10 - 2 * 3→ 4. - Errors:
SyntaxError(broken grammar) vsNameError(unknown name — forgot quotes / capitalizedPrint). Read the last line.
Objective 2 — Variables, types, expressions, I/O, strings
/→ float (10 / 2→5.0);//floors (7 // 2→3);%remainder (7 % 2→1).int("5") + 3→8;"5" + 3→ TypeError.input()returns a string. Slicing stop is exclusive:"PYTHON"[1:4]→YTH;"PYTHON"[-1]→N. f-strings insert values, e.g.f"Hi {name}"showsHi Adawhennameis"Ada".
Objective 3 — Booleans & conditionals
- Comparisons and
and/or/not.True and not False→True. if/elif/else: only the first true branch runs. Forscore = 75: printsC.=assigns;==compares.=in a condition is aSyntaxError.
Objective 4 — while & for loops
whileneeds a counter update or it loops forever.range(1, 5)→1, 2, 3, 4(stop excluded);range(0, 10, 2)→0, 2, 4, 6, 8.- Sum
range(5)→10. Nested loops: inner runs fully per outer step (2×3 → 6 lines). - Off-by-one: use
range(1, 6)to include 5.
Objective 5 — Functions
def f(a, b): return a + b→f(3, 4)→7.- No
return→None. Printing the result of a function that only prints shows the print, thenNone. - A variable made inside a function is local; using it outside →
NameError.
The classic-bug checklist (memorize)
= vs == · range stop is exclusive (off-by-one) · / gives a float (5.0) · "2" + "3" is "23" · capital Print / missing quotes → NameError · no return → None · input() returns a string · infinite while (no counter update).
Self-check (✓ when you can do it without notes)
- [ ] Predict
print(10 - 2 * 3),print(10 / 2),print(7 // 2, 7 % 2). - [ ] Slice a string and predict the result (remember the exclusive stop).
- [ ] Say which
if/elif/elsebranch runs for a given value. - [ ] Predict a
while/foraccumulator total and arange(...)list. - [ ] Explain
returnvsprintand whatNonemeans. - [ ] Take the Practice Midterm (O) and score yourself.
~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com