Python From Scratch — Part 1: Hello, World
Getting Python installed and running is the part that quietly stops more beginners than loops, classes, or neural networks ever will. Part 1 takes you from nothing installed — on Windows, macOS, or Linux — to your first running program, with a warning about the apostrophe that bites on line one.
Part 1 of 23 · Level: Beginner · From Hello World to Neural Networks
Every programmer you admire once sat exactly where you're sitting now: staring at a blank screen, not sure what to type, quietly wondering if they're the wrong kind of person for this. They weren't, and neither are you. By the end of this page you'll have Python installed and a running program with your fingerprints on it. That's the whole job today — no neural networks, no clever tricks, just getting the engine to turn over.
Getting Python onto your machine
You need the Python interpreter — the program that reads your code and actually does what it says. Get it from the one official source: python.org/downloads. Ignore the dozens of "easier" installers the internet will wave at you; the official one is easy enough and won't surprise you later.
Windows. Download the installer, run it, and — this is the one step people skip and then regret — tick the box that says "Add python.exe to PATH" on the very first screen, before you click Install. That checkbox is the difference between python working in your terminal and it throwing "command not found". If you already installed without it, no drama: run the installer again, choose Modify, and add it.
macOS. Download the macOS installer and run it like any other .pkg. macOS ships with an ancient Python for its own internal use — leave that one alone. The python.org installer drops a fresh, current version alongside it, and that's the one you'll use.
Linux. You very likely already have Python. If not, your package manager has it: sudo apt install python3 on Debian/Ubuntu, sudo dnf install python3 on Fedora, sudo pacman -S python on Arch. Distributions lean on Python internally, so it's rarely far away.
Now prove it worked. Open a terminal — Command Prompt or PowerShell on Windows, Terminal on macOS, whatever you use on Linux — and type:
python --version
Output:
Python 3.13.1
If that prints a version starting with 3, you're done. On macOS and Linux the command is often python3 rather than python:
python3 --version
Output:
Python 3.13.1
Any 3.x number is fine — the exact digits don't matter. Which brings us to the one version rule worth burning into memory.
Use Python 3, never Python 2
If you ever land on a tutorial that writes print "hello" with no parentheses, close the tab. That's Python 2, which reached the end of its life in 2020 and is not coming back. Everything in this series is Python 3, the only version anyone should be learning today. If python --version shows a 2.x, reach for the python3 command instead, and mentally swap python for python3 everywhere below.
Pick an editor, then stop thinking about it
You could write Python in Notepad. You shouldn't, but you could — the code is just text. What you actually want is an editor that colours your code and gently points at typos before you run them.
VS Code (code.visualstudio.com, free) is the safe default: install it, add the official Python extension when it offers, done. But this genuinely does not matter yet. PyCharm, Sublime, Neovim, the plain editor your OS came with — any of them is fine for print("Hello, world!"). The single worst thing a beginner can do here is spend three days comparing editors instead of writing three lines of Python. Pick one in the next five minutes and move on. You can switch later; nobody will file a complaint.
The REPL: Python's back-of-a-napkin
There are two ways to run Python, and you'll use both forever. The first is the REPL — Read, Eval, Print, Loop — an interactive prompt where you type one line and Python answers on the spot. Start it by running python (or python3) with no filename:
python
You'll get a >>> prompt. Type something, hit Enter:
>>> 2 + 2
4
>>> print("hi")
hi
>>> 10 * 60
600
Notice you didn't even need print for 2 + 2 — the REPL shows you the result of whatever you type. It's a calculator that happens to know all of Python, perfect for "wait, does this actually work?" moments. To leave, type exit() and press Enter (or Ctrl+D on macOS/Linux, Ctrl+Z then Enter on Windows).
The REPL is brilliant for experiments and useless for anything you want to keep — close the window and every line is gone. For programs you want to save and run again, you write a file.
Your first program: hello.py
Open your editor, make a new file, and type exactly this:
print("Hello, world!")
Save it as hello.py somewhere you can find it — the .py ending is what marks it as Python. Then, in your terminal, move into that folder and run it:
python hello.py
Output:
Hello, world!
That's it. That's a program. You wrote instructions, saved them, and handed the file to Python, which read it top to bottom and did what you asked. Every program in this series — right up to the neural network — is that same loop, just with more lines between the first and the last.
If you instead got python: can't open file 'hello.py', Python is running in a different folder from where you saved the file. Use cd to move into the right folder first (say, cd Desktop), then run it again. This trips up absolutely everyone once, so consider it a rite of passage rather than a failure.
What print() actually does, and those quotes
print() takes whatever you put between its parentheses and writes it out for you to read. The parentheses mean "call this thing" — you're telling the print function to go do its job. Whatever sits inside is what gets shown.
The "Hello, world!" part is a string — programmer-speak for a piece of text. Python needs you to wrap text in quotes so it can tell your text apart from actual instructions. And it happily accepts either single or double quotes, with no difference in meaning:
print('Hello, world!')
print("Hello, world!")
Output:
Hello, world!
Hello, world!
Use whichever you prefer, but be consistent. The one time it matters: when your text itself contains a quote. Wrap the whole thing in the other kind and the problem disappears:
print("It's a lovely day")
print('She said "hi" back')
Output:
It's a lovely day
She said "hi" back
Try wrapping It's in single quotes — 'It's' — and Python gets confused, because it reads the middle apostrophe as the end of the string. That's not you being bad at this; it's a real rough edge, and reaching for the other quote is the normal, boring fix.
Leaving notes with comments
Any line starting with # is a comment — Python ignores everything after the # on that line. Comments are notes for humans: future-you, mostly, who will read this next month and remember nothing.
# This line does nothing; Python skips it entirely.
print("Hello, world!") # A comment can also sit after real code.
Output:
Hello, world!
Use them to explain why something is there, not to narrate the obvious. A # print the greeting sitting above a print earns nothing. A # the upstream API rejects names longer than this earns its place, because it tells the next reader something the code can't.
When you get stuck
You will get stuck. Everyone does, constantly, forever — the difference between people who program and people who gave up is entirely about how they handle being stuck, not about avoiding it. A few reliable escape hatches:
Ask Python directly. From the REPL, help() pulls up built-in documentation. Hand it something you're curious about:
>>> help(print)
That prints the full rundown of what print can do. Press q to get back to the prompt.
Read the official docs at docs.python.org. They're genuinely good and always match the language exactly — no guessing whether some random blog post has gone stale.
Read the error message. When something breaks, Python tells you what went wrong, usually on the last line. It looks like noise at first and becomes your best friend by Part 5. Don't skim past it — the answer is often sitting right there in plain English.
Next up
You've got a working Python, an editor, and a program that runs — the genuinely hard part is behind you. In Part 2: Variables, Numbers & Strings, we stop printing the same fixed text and start storing values, doing arithmetic, and bending strings into whatever shape we need. That's where Python stops feeling like a party trick and starts feeling like a tool.
Jako Heiberg
Software developer with 40+ years of building things that work. Full-stack, FastAPI, React. Based in Cape Town, working remotely, worldwide.