Lecture 04 — First Python: State and Sequences

Position in the course

This is lecture 4 of 32. It belongs to the course arc described in the course outline and uses the standard interactive case method: display, attempt (5 minutes), discuss, reveal, name the technique.

This lecture runs as a workshop session (build-heavy; see the timing plan), not the standard four-case rhythm.

Learning objectives

By the end of this lecture students can do all three under time pressure, which is what the four cases exercise.

Prerequisite knowledge

Before this lecture: Lectures 02–03 — Pseudocode and flowcharts

Assumed fluencies:

Preparation task: Work through resources/python-setup.md; run any cs-013-style echo program once.

Detailed topic outline

Core (mandatory):

  1. Python as executable pseudocode
  2. state: variables, names, reassignment
  3. input/output and conversion
  4. lists and basic sequence operations

Extension (optional enrichment):

  1. a first debugger encounter
  2. from plan to run to check

Case sequence

CaseTitleDifficulty
cs-013Echo with LimitsBeginner
cs-014Course List CleanerFoundational
cs-015The Change MakerIntermediate
cs-016The Meeting SchedulerAdvanced

Display each case full-screen from the student page (cases cs-013–cs-016); instructor pages cs-013–cs-016 under case-studies/instructor/ hold the full solutions, reveal guides, and discussion prompts.

Timing plan (120 minutes)

Format: workshop session — deliberately not the standard case rhythm.

MinutesSegment
0–10Framing: the two patterns this workshop trains
10–45Cases 1–2 (cs-013, cs-014): two 5-minute attempts back to back, one joint discussion, two reveals
45–50Break
50–90Cases 3–4 (cs-015, cs-016): same double rhythm, harder material
90–110Deliberate-practice block: build or trace one of today's patterns end to end, instructor circulating
110–120Synthesis, exit questions, homework

Timing flexes with the room: if a case ignites the class, let the discussion run and compress the synthesis; if the attempts stall, harvest partial attempts rather than extending the clock.

Worked examples

Instructor demonstration to open the lecture: Type echo-with-limits (cs-013) from its pseudocode while narrating each decision; run it; break it with a boundary input on purpose.

Classroom activities

#ActivityMinutesFormat and prompt
1Build stations15Three stations (echo, list cleaner, change maker skeleton); pairs rotate every five minutes leaving a running program behind.
2Predict-then-run6Five short snippets are shown one at a time; everyone writes the output before it is run aloud.
3Error bingo5Cards with classic first-day errors (NameError on a typo, int('3.5'), off-by-one range); first pair to diagnose all five calls bingo.

Board plan

Instructor explanation notes

Reading the room. The first machine lab of the course. Expect enormous speed differences; the build stations exist so nobody is idle and nobody is bored. Publish the python-setup page a week ahead.

Running the reveal. Insist on predict-then-run for every demonstration: prediction converts watching into learning.

Lecture focus. One sentence to repeat verbatim: Predict, then run, then check — never just run.

Common misconceptions

Each case's instructor page lists the specific wrong turn to expect; the reveal should address it by name.

Student practice exercises

Core:

  1. Run the change maker (cs-015) for 4.19 and record the trace table.
  2. Write a program that reads numbers until 0 and prints the count of negatives.
  3. Break cs-013 with the nastiest legal input you can construct; explain the failure.

Enrichment (optional):

Formative assessment

Exit questions (choose one; answer on a card in 60 seconds):

  1. What does predict-then-run change about learning? Expected: prediction makes the run informative; mismatches are the lesson
  1. Name the three Python errors you met today and their causes. Expected: e.g. NameError (typo/undefined), ValueError on int('3.5'), IndexError on range end
  1. Why convert input strings before arithmetic? Expected: input() returns strings; arithmetic on them concatenates or fails

Cards are skimmed before the next lecture; three answers become the framing. Persistent wrong answers route students to the review stations of lecture 16 or to office hours.

Homework and preparation

Learning-outcome mapping

Differentiation