Back to the Introduction to Computer Science outline The Course Maker
Introduction to Computer Science outline
Week 8 · Lecture outline

Week 8 — Lecture Outline · Midterm Review (Cumulative, Weeks 1–7)

Introduction to Computer Science · CSCI 1101 Fall 2026 · Prof. Okafor Fictional sample

Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Purpose: a guided cumulative review of Objectives 1–5 before the Midterm — not new content. Re-walk each week's big idea, its exact syntax, and its classic bug, predicting and running every snippet.
Meeting pattern: 2 studio sessions × 75 min. Session 1 = Objectives 1–3; Session 2 = Objectives 4–5 + exam logistics.

Every output below was produced by running the code in Python. Run them live; have the room predict first.


Segment 1 — How to Review (8 min)

Tell students the midterm is mostly predict-the-output and debugging. The single best prep is to predict, then run — open the editor and check every example. Hand out the classic-bug list (Segment 8).

Segment 2 — Objective 1: Computing, print, Errors (18 min)

  • A program runs top to bottom; an algorithm is the plan. The computer does exactly what you wrote.
  • print(...) displays; quotes make a string; + joins strings but adds numbers.
  • Precedence: print(10 - 2 * 3) → run-verified 4 (× before −).
  • Errors: SyntaxError = broken grammar (missing )/quote); NameError = unknown name (forgot quotes, or capitalized Print). Read the last line.

Segment 3 — Objective 2: Variables, Types & Expressions (20 min)

  • Types: int, float, str, bool. / always gives a float: print(10 / 2) → run-verified 5.0.
  • // floors, % is remainder: print(7 // 2, 7 % 2) → run-verified 3 1.
  • Type conversion: int("5") + 38; but "5" + 3 is a TypeError.
  • I/O & strings: input() returns a string; slicing is exclusive on the stop — "PYTHON"[1:4] → run-verified YTH; f-strings insert values.

Segment 4 — Objective 3: Booleans & Conditionals (18 min) · Session 1 closes

  • Comparisons (==, !=, <, >=) and logic (and, or, not). print(True and not False) → run-verified True.
  • if / elif / else — only the first true branch runs: for score = 75, the elif score >= 70 branch prints C (run-verified).
  • Classic bug: = assigns, == compares. = in a condition is a SyntaxError.

Segment 5 — Objective 4: while & for Loops (24 min) · Session 2 opens

  • while runs while its condition is true; needs a counter update or it loops forever.
  • Accumulator: summing 1..4 with a while loop → run-verified 10.
  • for + range: the stop is exclusivelist(range(1, 5)) → run-verified [1, 2, 3, 4]; list(range(0, 10, 2))[0, 2, 4, 6, 8].
  • Sum with for: sum of range(5) → run-verified 10. Nested loops: the inner loop runs fully for each outer step.
  • Classic bug: off-by-one (use range(1, 6) to include 5); infinite while (forgot i = i + 1).

Segment 6 — Objective 5: Functions (18 min)

  • def name(params): ... return value. Call it and use the result: add(3, 4) → run-verified 7.
  • return vs print: a function with no return gives Noneprint(greet('Sam')) shows the printed line then None (run-verified).
  • Scope: a variable made inside a function is local — using it outside raises NameError.

Segment 7 — Mixed Predict-and-Run Drill (16 min)

Put 6–8 mixed snippets on slides spanning all five objectives; have the room predict each, then run it. Celebrate the misses — they're exactly the midterm traps.

Segment 8 — The Classic-Bug Checklist + Exam Logistics (18 min) · Session 2 closes

Print this for students:
- = vs == · off-by-one (range stop exclusive) · / gives a float (5.0) · "2" + "3" is "23" · capital PrintNameError · forgetting quotes → NameError · a function with no returnNone · input() returns a string · infinite while (no counter update).
Logistics: Midterm opens Mon Oct 19, due Sun Oct 25, 20 items, 100 points, no AI, one attempt. Take the Practice Midterm first.


Scope flag

This review covers only Objectives 1–5 (Weeks 1–7). Collections, files/exceptions, algorithms, recursion, and OOP (Weeks 9–15) are not on the midterm — they're on the cumulative final. Every output shown was produced by running the code.

~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com