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

Week 8 — Midterm Study Guide (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
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 * 34.
  • Errors: SyntaxError (broken grammar) vs NameError (unknown name — forgot quotes / capitalized Print). Read the last line.

Objective 2 — Variables, types, expressions, I/O, strings

  • /float (10 / 25.0); // floors (7 // 23); % remainder (7 % 21).
  • int("5") + 38; "5" + 3TypeError.
  • input() returns a string. Slicing stop is exclusive: "PYTHON"[1:4]YTH; "PYTHON"[-1]N. f-strings insert values, e.g. f"Hi {name}" shows Hi Ada when name is "Ada".

Objective 3 — Booleans & conditionals

  • Comparisons and and / or / not. True and not FalseTrue.
  • if / elif / else: only the first true branch runs. For score = 75: prints C.
  • = assigns; == compares. = in a condition is a SyntaxError.

Objective 4 — while & for loops

  • while needs 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 + bf(3, 4)7.
  • No returnNone. Printing the result of a function that only prints shows the print, then None.
  • 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 returnNone · 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/else branch runs for a given value.
  • [ ] Predict a while/for accumulator total and a range(...) list.
  • [ ] Explain return vs print and what None means.
  • [ ] Take the Practice Midterm (O) and score yourself.

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