Learning outcomes
By the end of this lesson you should be able to: explain what a program is in your own words; describe the difference between source code and what a computer actually executes; run a short Python program and correctly predict what it prints; and recognise a Python error message as feedback rather than failure.
Prerequisites
None. This is the first lesson of the course. You do not need any programming experience, and you do not need Python installed — every example shows its exact output inline.
The big idea
That definition is the whole course in one sentence, and most of what feels difficult about programming later is just the consequences of it. A recipe is a good analogy, with one important difference: a human cook fills in the gaps. If a recipe says "cook the onions until soft", a person knows what soft looks like. A computer does not. If you mean "until a fork sinks in easily", you have to say that.
Why this matters before anything else
Before learning any Python syntax it helps to understand the arrangement you are entering into. You are writing instructions for a processor that is extraordinarily fast and literal-minded. It will do ten million of your instructions per second and not one of them will it interpret charitably. This is why programmers talk about "bugs" rather than "misunderstandings": when the output is wrong, the machine did exactly what it was told, and the instruction was wrong.
There is a chain between what you type and what the machine does. You write source code — text, in a language like Python. Another program, called an interpreter, reads that text and translates each line into the processor's own instructions, then runs them. You never speak to the processor directly; you write Python, and the interpreter carries the message. This is why a "syntax error" is possible: it is the interpreter telling you it could not finish reading the sentence.
Worked example 1: your first program
The traditional first program does one thing: it announces itself. Two lines, each a complete instruction.
print("Welcome to Introduction to Programming!")
print("2 + 3 =", 2 + 3)Welcome to Introduction to Programming!
2 + 3 = 5Read it as three facts. print is an instruction that writes to the screen. Whatever you put inside the quotes is written exactly as written, so the first line prints the greeting and the second prints the fragment "2 + 3 =". The part without quotes, 2 + 3, is not text — it is arithmetic the interpreter evaluates before printing, which is why the output shows 5 and not the characters 2 + 3. That distinction, quoted text versus unquoted expression, is the first real fork in learning to program, and it is worth pausing on.
Worked example 2: a program that remembers
Real programs do not just recite; they keep hold of things and act on them later. Here a name is stored and then used twice. Two identical-looking instructions produce different output, because the stored value changed between them.
name = "Ada"
print("Hello,", name)
print("Your name has", len(name), "letters")Hello, Ada
Your name has 3 lettersThe line name = "Ada" is an assignment, and it reads backwards to most beginners: it means "put the value on the right into the box labelled on the left", never the reverse. So Ada is stored, and whenever the program later says name it means whatever is currently in that box. The second and third lines both print something about name, and they differ because they ask different questions of the same stored value — one reports it, the other measures it with len().
Common mistakes
Watch outSpelling print as Print or PRINT. Python is case-sensitive; Print is not the same instruction as print, and the interpreter will report that Print is not defined. If an error says something "is not defined", check capitalisation first.
Watch outForgetting the quotes around text. Writing print(Hello) makes Python treat Hello as a stored name rather than text, and since nothing was stored under that name you get NameError. Text must be quoted; numbers and arithmetic must not be.
Watch outMixing up the two directions of =. name = "Ada" stores a value. Writing it as "Ada" = name is nonsense to the interpreter, because you cannot store into a piece of text. The value always moves right to left.
Check your understanding
What does the interpreter do with your source code?
In print("2 + 3 =", 2 + 3), why does the output show 5 rather than 2 + 3 twice?
A program stores 7 under the label score, then runs print(score + 1). What is printed, and what is in score afterwards?
Multiple choice
Which statement best describes a program?
What is the interpreter for?
What is the output of print("6 * 7")?
What does print(10 - 4) print, and why?
Which of these produces a NameError when run?
In the line name = "Ada", which reading is correct?
What does len("Python") evaluate to?
A beginner writes Print("hi") and sees an error mentioning something not defined. What is the most likely cause?
Summary and next
A program is literal, ordered instructions run by an interpreter that translates your text for the processor. Quoted material is written verbatim; unquoted material is worked out first. A single = stores a value under a label, and reading that label later does not change what is stored. Errors are the interpreter reporting that it could not follow an instruction, and they are information rather than failure.
Next: variables and types. Lesson 1 stored text under a label; the next lesson covers what else can be stored — whole numbers, decimals, truth values — and why the distinction changes what your instructions are allowed to do to them.