Addaly is in open beta. Things will change, and AI answers can be wrong — check anything that matters.

What a program is, and running your first line

Python, From Zero, For AI · lesson 1 of 10 · 6 min

A program is a list of instructions with no gaps

A program is a list of instructions written so a machine can follow them without asking you anything. That last part is the whole difficulty.

If you tell a person "add up the prices and tell me the total", they fill in what you left out. They know prices are numbers. They know to skip the blank line. They know what to do if one price is missing. A computer fills in nothing. It does exactly what is written, in the order it is written, and stops the moment something does not make sense.

Python is one way of writing those instructions. It was designed to look close to English, which helps you read it, and occasionally fools you into thinking it will guess what you meant. It will not.

Two places to type Python

The interactive prompt. Open a terminal and type python3 (on Windows, usually python). You get a prompt like this:

Python 3.12.3
>>>

Everything you type after >>> runs the instant you press Enter. This is for trying things.

A file. Put your instructions in a file called hello.py, then run it:

bash
python3 hello.py

This is for programs you want to keep. Both run the same Python.

If python3 is not found, install Python from python.org, or with your system's package manager.

Your first line

Type this into a file and run it:

python
print("Hello from Lagos")

Output:

Hello from Lagos

print is an instruction that puts something on the screen. The round brackets hold what you want printed. The quote marks say "this is text, not a command". Without the quotes, Python would look for something named Hello and fail.

Lines run top to bottom, one at a time

python
print("first")
print("second")
print(2 + 2)

Output:

first
second
4

Python read line one, did it, then line two, then line three. It does not look ahead. It does not reorder. This sounds obvious now and will save you an hour later.

Notice the third line: 2 + 2 was worked out to 4, and print put that on the screen. Python does arithmetic with + - * /. Try print(7 / 2) and you get 3.5, not 3.

The difference that catches everyone once

At the interactive prompt, typing an expression shows you its answer:

>>> 2 + 2
4

In a file, it does not. Put a file containing only this line:

python
2 + 2

Run it. Nothing appears. The file is not broken. Python did the addition, produced 4, and threw it away, because nothing asked for it to be shown. The interactive prompt prints results as a convenience to you while you experiment. A running program has nobody to be convenient for.

So in files: if you want to see it, print it.

Notes to yourself

A # means the rest of the line is for humans and Python ignores it:

python
# prices are in naira
print(2500 * 3)

Try this now

Make a file, put four print lines in it, and deliberately break one: remove a closing bracket. Run it. Read what Python says. You are going to see a lot of those messages, and lesson seven is entirely about reading them.

Before you move on

A student writes a file containing exactly one line, `2 + 2`, and runs it with `python3 sums.py`. The terminal prints nothing at all and gives no error. What happened?

Pick the one you would defend. Nobody sees your answer.

No ads. No data sale. No public scores on people. Ever.

© 2026 Addaly