an ELI5 one-pager

Python from scratch

Python is a way of writing instructions for a very literal, patient robot. It reads your lines top to bottom and does exactly what they say — no more, no less. Here are the bricks you build everything from.

01Saying things out loud

print() is how Python speaks. Whatever you put in the brackets, it shows on screen.

Think of it likeHanding the robot a megaphone. Whatever you write inside, it reads aloud.
print("Hoi, Dick!")

02Variables

A variable is a labelled jar. You put something in it and stick a name on the front, then reuse the name later.

Think of it likeA labelled box in a warehouse. The label is the name; the contents can change any time.
name  = "Dick"
age   = 42
print(name)   # -> Dick

03Kinds of stuff

Jars hold different types: whole numbers, text ("strings"), true/false, and lists of things.

Think of it likeA shopping list vs. a price vs. a yes/no answer — different sorts of thing, handled differently.
price   = 3.5          # number
label   = "pallet"    # string (text)
in_stock = True        # true / false
crates  = ["A", "B", "C"]  # list

04Notes to yourself

Anything after a # is a comment. Python ignores it completely — it's just for humans.

Think of it likeA sticky note on the machine. Useful to you, invisible to the robot.
# count today's orders
orders = 128

05Making decisions

if / else lets Python choose a path depending on whether something is true.

Think of it likeA bouncer at the door: on the list? Come in. If not? Take the other route.
if age >= 18:
    print("Welkom")
else:
    print("Sorry, nee")

06Repeating a chore

A for loop does the same step once for every item in a list.

Think of it likeAn assembly line stamping every package as it passes — same action, each parcel.
for crate in crates:
    print("Scanning", crate)
# -> Scanning A, B, C

07Reusable recipes

A def bundles steps under one name. Write it once, call it whenever you need it.

Think of it likeA recipe card. You don't re-explain how to make coffee each time — you just say "make coffee".
def greet(who):
    print("Hallo", who)

greet("Philip")  # -> Hallo Philip

08The indent matters

Python uses spacing to show what belongs inside what. The indented lines are "inside" the line above.

Think of it likeAn indented sub-bullet list. The nesting is the meaning — get it wrong and the sense changes.
if in_stock:
    print("ship it")   # inside the if
print("done")          # outside — always runs

Running your first script

1   Put your code in a file ending in .py, e.g. hello.py.

2   Open Terminal in that folder and type python3 hello.py.

3   The robot reads top to bottom and does exactly what you wrote. That's the whole game.