Unit 2 · Programming 1 · Lesson 2.1

Your First Real Program

In 0.3 you programmed a person and watched them take you literally. Today you do it to a machine that never gets tired of being literal — and you break it on purpose.

Big Idea 1 — Creative DevelopmentPrograms — the new region

Before this lesson — read on Runestone

A gentle first look at running Python. Skim it — you’ll do the real work here. Enrolled in our Runestone course? Open it from there so your progress counts.

1

Where We Are

People→ Bits→ Programs→ Internet→ Security→ Big Data→ Impact

New region: Programs. For three weeks everything was a representation — how the world becomes bits. Now you start telling the machine what to do with them. The bits never went away; they’re underneath every line you write.

2

The Hook

“Make a peanut butter sandwich.” Remember 0.3, when your instructions were too vague and the sandwich came out wrong? The machine you meet today is that literal — forever, without complaint.

Here is the good news buried in that: the computer is not judging you. When your program breaks — and it will, today, on purpose — it is not saying you’re bad at this. It is telling you, very precisely, which instruction it couldn’t follow. Learning to read that message is the whole job. Most people quit programming because they think errors mean failure. You’re going to spend day one proving they mean the opposite.

3

The Idea

A program is a list of instructions, run top to bottom, in order. Each line is a program statement — one thing you’re asking the machine to do. Your first verb is print: it displays whatever you put in the parentheses.

print("Hello, world!")   # displays: Hello, world!
print("I am a program.")  # the next line runs after the first

Three things are load-bearing there, and every one is a rule the machine enforces exactly:

Quotes mark text (a string) — they must come in matching pairs. Parentheses hold what print acts on — they must open and close. Spelling counts — print is a word Python knows; prnt is not.

Anything after a # on a line is a comment — Python ignores it completely. Comments are notes to humans: the future you, or a partner reading your code. They change nothing about how the program runs, and they are one of the cheapest good habits in this whole course.

Syntax is the grammar of a programming language — the exact rules for how code must be written. English lets you be sloppy and still be understood. Python does not: one missing quote and it stops. That strictness feels hostile at first and becomes a superpower later, because the machine catches your mistake the instant you make it.
4

Try It — Break It, Read It, Fix It

Three programs, each broken one small way. Hit Run to see exactly what Python says, then Fix to see the one change that makes it work. Read every error message — that is the skill.

Notice the pattern: the error message names the kind of problem and usually points near the line. It is not punishment — it is the most helpful thing a computer ever does for you.

5

Vocabulary

Three words you used today. Now they get names.

program statement Programs
A single instruction in a program — one line asking the machine to do one thing. A program is a sequence of these, run in order.
syntax Programs
The set of exact rules for how code must be written in a language. Break a syntax rule — a missing quote or parenthesis — and the program will not run at all.
comment Programs
A note in the code for humans to read, marked with # in Python. The machine ignores it entirely; it exists to make the program understandable.
6

Check

Five questions in AP format. Pick an answer to see feedback immediately.

0 of 5 answered
7

Impact Check

The machine does exactly what you said

In 1962, NASA lost the Mariner 1 probe less than five minutes after launch. Investigators traced it, in part, to a tiny mistake in the guidance software — a single missing mark in a formula. The rocket did precisely what the code told it to. It just wasn’t what anyone meant.

That is the double edge of a machine that takes you literally: it will never guess your intention and never quietly fix your typo. Everything good about programming and everything dangerous about it come from the same fact. Which is exactly why the boring habits — run it, read the error, comment your intent, test it — are not busywork. They are how you make sure “what you said” and “what you meant” are the same thing.

8

Connections

Came from 0.3 — “program the teacher” taught you that instructions must be precise and ordered. Python is that game with a partner who is perfectly literal and infinitely patient.
Next in 2.2 — you give the machine a memory. Variables let a program hold on to a value and use it later, and the AP exam’s pseudocode enters the picture.
Returns in 2.8 — today you met errors informally. Later this unit you learn to name them — syntax, run-time, logic — which is a recurring easy exam question.
Returns on the exam — Big Idea 1 asks about program purpose and about finding and fixing errors. You’re building the instinct now: read the message, don’t panic.
← 1.15 Flex Day