Lecture Notes — Lecture 02: Pseudocode as Precision

Companion to the lecture plan and the worked examples. Read the Definitions before class, the Explanation after it; the practice questions and the lecture quiz close the loop.

Definitions

Explanation

Why not just Python? Syntax is noise when you are learning to think. Pseudocode keeps only the reasoning: sequence, selection, iteration, state. Block I-II work is required in pseudocode first for exactly this reason.

The course grammar. READ / WRITE for input-output; x <- expression for assignment; IF/ELSE for selection; WHILE and FOR for iteration. One statement per line, one job per statement. This grammar is small on purpose - it fits on an index card and in your head.

Precision levels. 'Check the password' (vague) → 'check length is 8-12, then first char is a letter, then at least one digit' (precise) → 'on failure, name the FIRST rule broken' (testable). Push every statement down one level before coding.

State and assignment. Assignment c <- c + 1 is not algebra; it is an order: compute the right side with current values, then store. Traces make this visible.

Order of tests matters. Validation must report the first failing rule, so the tests must be ordered deliberately. Writing the tests in a random order produces messages that contradict the spec.

Examples

The lecture's worked examples live in examples.md; the case studies this lecture builds on are worked in class from the projector. The case sequence with difficulties:

Common misconceptions

Summary and key takeaways

  1. One statement, one job; trace before you trust.
  2. Assignment is an order, not an equation.
  3. Order the validation tests; report the first failure.
  4. Pseudocode is a contract another human can execute.

Practice questions

Where this leads

Next lecture: Flowcharts and Control Flow. The quiz below checks this lecture's essentials before we build on them.