python1# hello.py: greets you2print("Hello!")3name = input("Name? ")4print("Hi,", name)IndentationError2 + 3hello.pyHello!Name?'Sam''Sam'
Code card: hello.py; the highlighted line is the one runningPython interpreter: reads your code and carries it outTerminal: where you type and where print() and input() writeMemory box: the value stored under the name nameThe interpreter, python, runs code two ways: one line at a time at the >>> prompt, or a whole file such as hello.py. Each step lights the parts it is about. A token hops along the step's arrow: from the file to the interpreter, from a line to the terminal, from the terminal into the memory box for name, and back out for the greeting. The terminal's lines crossfade and the answer is typed in letter by letter. In the last step line 2 slides right by two stray spaces: Python refuses to run any of the file and reports an IndentationError.

Meet Python

  1. Python is a programming language: a way to write instructions for a computer in words that read almost like English. A program called the interpreter, python, reads your code and carries it out.

Line by line

One rule

Try it yourself

;; step 1/9
# Python code reads almost like English:
print("Hello!")

# the interpreter is the program that runs it:
$ python --version
Python 3.14.0      # your version may differ

On macOS and Linux the command is often python3 rather than python; on Windows the py launcher also works. The $ and > at the start of a line are the terminal's own prompt: you do not type them. Python reads and compiles the whole file before it runs the first line, which is why a badly indented line 2 stops the program before Hello! is printed. In the real message, the ... is the full path to the file.