Grade 7 Computer Science
The year the computer stops being magic
A first year in computer science, built entirely around one question: what exactly does the computer do, and why is that almost never what you meant. We begin with a program being carried out literally and with the order of the steps being part of the meaning, give names to values and see how a type decides what an operation does, learn to branch and to repeat, hold many values in one list, and give a name to a whole passage of code so that one can think in larger terms. We then stop on the question of how a bug is found at all and how one knows it is fixed, and close with the question of where the meaning of the data a computer holds comes from. The code throughout the year is written in Python, but the ideas are not tied to any language. The year ends with a final exam over the whole of it.
Values and names
- A variable is a name, not a box
- A type decides what an operation does
- An expression — what evaluates to what
- A good name is documentation
- Truth values
- Common mistakes about values and names
- Summary practice — values and names
Decisions
- A branch — exactly one path
- Combining conditions
- A chain of conditions and the order of testing
- Covering every case
- A branch inside a branch
- Common mistakes about decisions
- Summary practice — decisions
Loops
- A loop — repeating without duplicating
- A loop over a collection
- While a condition holds
- An accumulator — carrying a result between rounds
- Leaving early and skipping
- Common mistakes about loops
- Summary practice — loops
Functions
- A function — a name for a passage of code
- Parameters — receiving values
- Returning a value or printing
- Where a name lives
- Breaking a program into functions
- Common mistakes about functions
- Summary practice — functions
Bugs and testing
- Three kinds of bug
- Narrowing the search
- Reading an error message
- Choosing test cases
- Fixing without breaking
- Common mistakes about bugs
- Summary practice — bugs and testing
How a computer holds information
- Everything is numbers
- Why two digits suffice
- Text as numbers
- A picture as numbers
- Why a file can shrink
- Common mistakes about representing information
- Summary practice — representing information
Final exam — Grade 7 Computer Science
- Final exam — Grade 7 Computer Science