Lesson 1: talking to the computer in words
Set up Linux, a tutor and Python, then a first program
Sessions
Laura, from my drawing of Munch’s painting (1899), made to talk with Runway Act-Two. Later in the course: how.
Why are we doing this?
An AI can install software, add up numbers and write proofs faster than either of us ever will. So why learn any of it?
For the same reason people learned pure math long before anyone needed it. Almost nobody uses calculus at work. What it built was the ability to understand: to follow an argument, see why it holds, and notice when it doesn’t.
That’s the point of this course: not to get the computer to do things, but to understand what it did, and why, well enough to catch it when it’s wrong.
To check your understanding as you go, guess what each command will do before you run it. When the computer surprises you, that’s the interesting part: guess why, in your own words, check with Claude, and ask your teacher for help.
This lesson is five short sessions, each one sitting of 15 to 30 minutes: setting up Linux, a tutor and Python, a shell and an editor, and at the end your first program. Do one session, stop whenever you like, and come back: the list of sessions at the top of the page shows where you are and takes you back there.
Each grey box has a copy button in its top right corner. Paste into the terminal with Ctrl+Shift+V and press Enter. Read the sentence above each box before you run it.
Turn on Linux (20 min session)
Turn on Linux (WSL)
Underneath the windows and buttons, a computer works with text. A terminal is a window where you talk to it in words. We’ll use Linux, running inside Windows (that’s WSL, Windows Subsystem for Linux).
- Shrink this browser window to about half the page
- Click the 4 blue square logo which is called Start and type PowerShell.
- Right-click Windows PowerShell, choose Run as administrator, and click Yes.
- Paste this and press Enter:
wsl --install ubuntuWhen it says so, restart the computer. When the computer comes back up, again click the windows button, and run Ubuntu, or if it’s not there, terminal, then wsl. A window called Ubuntu (our kind of Linux) then opens and asks you to make up a username (short, lowercase, no spaces) and a password.
When you type it, nothing appears, not even dots. That’s normal. Type it anyway and press Enter.
From now on, open Terminal from the Start menu and pick Ubuntu from the ▾ menu next to the tabs.
Look around
The line ending in $ is the prompt: the computer waiting for you.
Linux has directories, which are also called folders. When you work with Linux, you’re in a working directory, and you can have Linux print your working directory:
pwdpwd prints where you are, something like /home/anna: your home folder, written as a path (folders inside folders, separated by /).
To list what’s in the folder, type:
lsYou’ll see a lot of files there. However, you’ll want to keep your files for this course organized, so you’ll make a directory:
mkdir course
cd course
pwdBefore the last line, guess what pwd will print now. (mkdir makes a folder, cd goes into one, cd .. goes up a level.)
Stop the password questions
Commands starting with sudo run as the administrator, and Linux asks for your password each time. The Windows login already protects this computer, so we tell Linux to stop asking:
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/$USER
sudo chmod 0440 /etc/sudoers.d/$USERA tutor, then Python (25 min session)
Your tutor: Claude Code
Claude is an AI, a language model: it learned from a huge amount of text to predict what words come next. That turns out to be enough to explain things and write code. It also makes Claude very good at sounding right. Usually it is right. Sometimes it isn’t, and it can’t always tell. That’s why you check.
Claude Code lets you talk to Claude in the terminal. You’ll need a Claude account.
curl -fsSL https://claude.ai/install.sh | bashcurl downloads the installer, and | bash runs it (the |, a pipe, sends one command’s output into the next).
Claude could do this whole course by itself. That’s why we tell it not to. This box writes a file called CLAUDE.md: standing instructions Claude reads every time it starts in this folder.
cat > ~/course/CLAUDE.md <<'EOF'
# Tutor mode
I'm a beginner learning to program, and above all to reason.
The point is that I work things out myself.
You're my tutor, not the one doing the work.
- Never write the code for my exercises,
and don't run commands or edit files for me.
If you solve it, the lesson is lost.
- If I paste an error message, explain in plain words
what it means and where to look. One hint, not the fix.
- If I ask what a command does, explain it simply,
then ask me to predict what will happen before I run it.
- Ask me "why?" often, and look for the hole
in my explanations.
- If I ask how you work, or why AI gets things wrong,
explain honestly and simply. That's part of the course.
- Allowed: if I ask for code *to referee*
(with a hidden bug for me to find), write it.
- Keep answers short. Use everyday words.
EOFPress Alt+Shift+D to split the window into two panes. In the right pane, start Claude:
cd ~/course
claudeThe first time, it opens a browser to log in. Claude asks before it does anything on your computer: say no unless you understand what it’s asking.
Try two questions: “What did the cat > CLAUDE.md command I just ran do?” and “When are you most likely to be wrong?”
From now on: left pane, you work. Right pane, you ask.
Claude only knows what you tell it. A good question says what you did, what happened, and what you think: “I typed 7 / 0 into Python and got this error: (paste). I think it means you can’t divide by nothing. Am I right?” Errors are normal. Read each one yourself first and guess, then paste it with your guess. Fixing it is your job.
Python
In the left pane:
python3The prompt changes to >>>: you’re talking to Python now. Guess each answer before pressing Enter:
2 + 2
7 / 2
7 // 2
7 % 2
2 ** 10/ divides. // says how many whole times 2 goes into 7, and % says what’s left over: 7 is 3 twos and 1 more. ** is a power: 2 times itself 10 times.
To check your understanding: what are 17 // 5 and 17 % 5? Decide, then type them. (They’re 3 and 2, because 17 is 3 fives and 2 more.)
Your first error
Now ask for something impossible:
7 / 0Python answers with several lines in a pile. Read the last line first: it names the problem. Guess what it means, in your own words, then paste the whole thing to Claude, in the right pane, with your guess, as in Asking well above.
Notice that the >>> came back: an error stops one line, not Python. Leave Python with Ctrl+D.
A recipe makes cookies in trays of 12. You have 40 cookies’ worth of dough. Use // and % to say how many full trays you can bake, and how many cookies are left over. Guess first.
Boxes and types (20 min session)
Boxes
Start Python again in the left pane, and predict each line before pressing Enter:
python3x = 5
x + 1
x
x = x + 1
x
x == 6
x == 7x = 5 makes a box called x and puts 5 in it. x + 1 works out an answer but leaves the box alone.
In maths, x = x + 1 is nonsense. In Python, = means “work out the right side, then put it in the box on the left”.
== asks whether two things are equal, and the answer is True or False. One = stores, two == ask. Mixing them up is one of the most common mistakes in programming.
Three kinds of value
Every value has a type, and type() tells you which. Guess each answer, then press Enter:
type(7)
type(7 / 2)
type("7")
"3" + "4"
"3.5" + 1intis a whole number:7.floatis a number with a decimal point:3.5./always gives a float, even for8 / 2.str(a string) is text, in quotes:"7"is the character 7, not the number.
So "3" + "4" joins two pieces of text: '34'. And "3.5" + 1 stops with an error, because Python won’t guess whether you meant text or a number. Read the error’s last line and say what it means.
To turn text into a number, say which kind you want:
float("3.5") + 1
int("3") + 4Questions: input
input() asks the person at the keyboard, waits for Enter, and hands back what they typed. Type 6 when it asks:
servings = input("How many servings? ")
servings * 2Did you expect 12? Decide why it isn’t, before you read on.
input() always hands back text, even when you type digits. "6" * 2 is the text twice: '66'. To get a number, wrap it in int():
n = int(servings)
n * 2Sentences with values in them: f-strings
A recipe for 2 needs 250 g of flour, so 125 g a serving. Put the answer in a sentence:
print(f"{n} servings need {n * 125} g of flour")The f before the quote makes an f-string: anything in { } is worked out, and its value goes into the text. Leave Python with Ctrl+D.
In python3, ask for a number of cookies with input(), and print a sentence saying how many trays of 12 that fills. Guess what happens if you forget int(), then try it.
A shell and an editor (25 min session)
A friendlier shell: fish
The program that reads what you type is the shell. Ubuntu’s is bash. We’ll use fish, which helps you type less. Ask Claude what chsh does, and predict what will change, and when:
sudo apt update && sudo apt install -y fish
sudo chsh -s /usr/bin/fish $USER(apt installs software.) Close the left pane (exit) and open a new one with Alt+Shift+D. Was your prediction right?
Fish suggests the rest of a command in grey from what you typed before (→ accepts it), and Tab finishes names. ↑ brings back earlier commands.
Fish doesn’t know yet where Claude was installed. Tell it once, in fish’s settings file, config.fish (>> adds a line to the end of a file):
echo 'set -gx PATH ~/.local/bin $PATH' >> ~/.config/fish/config.fish
Close this pane (exit) and open a new one with Alt+Shift+D: fish reads config.fish each time it starts.
To check your understanding (ask Claude if you’re stuck): what is a “path”, and why did bash find Claude but fish didn’t?
An editor: nvim
To write programs we need a text editor. nvim runs inside the terminal. This also installs python3-tk, the window library lesson 3’s drawings use, so nothing else needs installing later:
sudo apt install -y neovim python3-tk
cd ~/course
nvim hello.txt
nvim has two modes, and most nvim confusion is forgetting which one you’re in:
- Normal mode, where it starts: every key is a command.
xdeletes a letter,uundoes. Type a word here and each letter does something, usually something strange. - Insert mode: keys type letters, like any other editor. The bottom line says
-- INSERT --.
i goes from normal to insert; Esc goes back. Why two modes? So every key can be a command without holding Ctrl. When in doubt, press Esc: it always lands you in normal mode, and a second press does no harm.
Here are all the keys this course uses. You won’t remember them; keep this card open beside you. Every edit later in the course says which keys it needs.
| Press | What it does |
|---|---|
i |
start typing (insert mode) |
Esc |
stop typing (back to normal mode) |
| Backspace | delete the letter before the cursor (insert mode) |
:wq Enter |
save and quit |
:q! Enter |
quit without saving |
| arrow keys | move around |
:5 Enter |
jump to line 5 (any number) |
G |
jump to the last line |
x |
delete the letter under the cursor |
dd |
delete the whole line |
u |
undo (press again to undo more) |
o |
open a new line below, and start typing |
O |
open a new line above, and start typing |
cc |
retype the whole line (its indent stays) |
>> |
indent the line (4 spaces, in a .py file) |
:Tutor Enter |
nvim’s own lesson, for more |
Every key except Backspace is pressed in normal mode.
Press i, type hello, press Esc, type :wq, press Enter. What will this print?
cat hello.txt
Try fixing things: nvim hello.txt, press x. Which letter goes? Then u to bring it back. Still in normal mode, type ox. Does x delete a letter again? Decide before you read on.
o is a command too: open a new line below and switch to insert mode. So the x after it is just a letter, on a new line. Esc, then u until it’s hello again, and :wq.
Stuck in nvim? Press Esc a few times, then :q!.
A shopping list, edited
The line keys matter most once a file exists. Make a list:
nvim list.txt
Press i and type three lines, flour, sugar and eggs, with Enter between them. Then Esc, and:
G, thenO, typebutter,Esc.:1Enter, thendd.:2Enter, thencc, typemilk,Esc.>>, then:wqEnter.
Before you run the next box, write down exactly what the file says now, line by line.
cat list.txt
It says sugar, then milk pushed to the right, then eggs. If yours differs, find the step where your picture and nvim’s parted. That’s how you’ll read programs, too: one step at a time.
A first program (20 min session)
Save it, run it
At the >>> prompt, everything you type is gone when you leave. A program is the same lines, saved in a file, so they run again whenever you like.
cd ~/course
nvim recipe.py
Type this in (i first, Esc and :wq at the end):
servings = int(input("How many servings? "))
flour = 250 * servings / 2
print(f"Flour: {flour} g")The recipe is written for 2 servings and needs 250 g of flour. int(input(...)) asks, and turns the answer into a number at once: whatever input hands back goes straight into int.
What will it print if you type 6? Decide, then run it:
python3 recipe.py
Did you predict 750.0, with the .0? (/ always gives a float.)
An error with a line number
Make a typo on purpose: change print to prin (nvim recipe.py, :3 Enter, arrow onto the t, x, :wq Enter). Run it again and type 6.
Read the error from the bottom up: the last line says what went wrong, and a few lines up, line 3 says where. Python ran lines 1 and 2, asked you the question, and stopped only when it reached the typo. Fix it (:3 Enter, arrow onto the (, i, type t, Esc, :wq Enter), and run it once more.
Copy before you change: cp
Your next program grows out of recipe.py. Don’t change recipe.py itself; copy it:
cp recipe.py recipe2.py
ls
cp copies a file: first what to copy, then the new name. Now there are two, and recipe.py still works whatever you do to recipe2.py. Every program from here on starts as a copy of the last one.
To check your understanding: what would cp recipe2.py recipe.py do? Decide before you read on.
It would copy recipe2.py over recipe.py. cp doesn’t ask: the old recipe.py would be gone, with no undo. First name: what you have. Second name: what you’re making.
Now add sugar to the copy (nvim recipe2.py, G, o, type the two new lines, Esc, :wq):
servings = int(input("How many servings? "))
flour = 250 * servings / 2
print(f"Flour: {flour} g")
sugar = 100 * servings / 2
print(f"Sugar: {sugar} g")Predict both lines for 6 servings, then run it:
python3 recipe2.py
Look at the two lines that work out an amount. What’s the same in both? Lesson 2 gives that part a name.
Aside: mv and rm
Two more file commands finish the set. mv renames a file; rm removes one. Predict what ls shows, then run it:
cp recipe2.py spare.py
mv spare.py extra.py
ls
rm extra.py
ls
rm is permanent
mv replaces a file that already has the new name, without asking. rm removes a file with no trash and no u. Read the name twice before you press Enter.
Copy recipe2.py to cookies.py, and change the copy to ask how many cookies you want, then print how many full trays of 12 that is, and how many are left over.
On paper
Answer without running it, then check: what does print(7 // 2 + 7 % 2) print?
What we did today
- Set up Linux, with Claude as a tutor, plus fish, nvim and Python.
- Met Python’s numbers, text and types, and your first errors.
- Wrote a program, saved it, ran it, and copied it before changing it.
The computer did the arithmetic. You predicted it first.