What you'll learn
Welcome to your first step as a Python developer. Before writing much code, this module builds the mental model that makes everything click — what programming is, how Python turns your text into a running program, why Python became one of the most loved languages in the world, and how to write and run your first program.
By the end of this module you'll be able to:
- Explain what programming is and how a computer runs your instructions
- Describe how Python runs code — the interpreter, CPython, and bytecode
- Understand what Python is and the huge range of things it powers
- Install Python and use the interactive interpreter (the REPL)
- Write, save, and run your first Python program
- Recognise the anatomy of a Python program, including why indentation matters
- Comment your code and appreciate the "Zen of Python"
How to use this lesson
What is programming?
A computer is astonishingly fast but completely literal — it does exactly what it's told. Programming is the craft of writing precise, unambiguous instructions that a computer can follow to solve a problem or perform a task.
The instructions you write in a language like Python are called source code. But a computer's processor only understands machine code — raw numeric instructions. Something has to translate your readable Python into something the machine can run. How that translation works is the key idea of this module.
Key idea
Compiled vs interpreted languages
There are two classic ways to turn source code into something that runs. Compiled languages (like C or C++) use a compiler to translate the entire program into machine code ahead of time, producing a file that runs directly on the processor — very fast, but tied to one platform.
Interpreted languages run your code through another program — an interpreter — that reads and executes it as the program runs. This is wonderfully flexible and portable, and it's the model Python follows. Python is often called interpreted, though under the hood it uses a clever hybrid step you'll see next.
Note
What is Python?
Python is a high-level, general-purpose programming language created by Guido van Rossum and first released in 1991. It was designed around one core idea: code should be easy to read and write. Its clean, English-like syntax is a huge part of why it's the most popular language for beginners and a favourite of professionals.
Three decades on, Python is beloved because it is:
- Readable — the syntax reads almost like plain English
- Batteries included — a huge standard library and a vast ecosystem of packages
- Versatile — used across an enormous range of fields
- Beginner-friendly, yet powerful — easy to start, deep enough for experts
Data Science & AI
The #1 language for machine learning, analytics, and research.
Web Development
Powers backends with Django, Flask, and FastAPI.
Automation & Scripting
Automate boring tasks, files, and workflows in a few lines.
Everything else
DevOps, scientific computing, finance, game scripting, and more.
Python 2 vs Python 3
How Python runs your code
The standard Python you'll install is called CPython (Python's reference implementation, written in C). When you run a program, CPython quietly does two things: it compiles your source into an intermediate format called bytecode, then a component called the Python Virtual Machine (PVM) executes that bytecode:
You never see the bytecode step — it happens automatically (sometimes cached in .pyc files to speed up future runs). Because your program targets the PVM rather than a specific operating system, the same Python code runs unchanged on Windows, macOS, and Linux.
Key idea
Installing Python & the REPL
Getting set up takes just a few steps:
- Download Python 3 from python.org (on Windows, tick "Add Python to PATH" in the installer). macOS and Linux often have Python already, but install a current version to be sure.
- Install an editor — VS Code or PyCharm are excellent and free.
- Verify it works by checking the version in a terminal:
python --versionPython also gives you an interactive playground called the REPL (Read-Eval-Print Loop). Type python in a terminal and you can run code line by line, seeing results instantly — perfect for experimenting. The >>> is Python's prompt:
>>> 2 + 3
5
>>> name = "Sara"
>>> print(f"Hi, {name}!")
Hi, Sara!
>>> len("Python")
6Tip
Your first program: Hello, World!
By tradition, the first program in any language prints "Hello, World!". In Python, that's a single, readable line. Press Run to see it work:
print("Hello, World!")Compare that to the same program in a language like Java, and Python's design philosophy jumps out immediately:
Java — "Hello, World!"
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}Python — "Hello, World!"
print("Hello, World!")Same result, one line. No class, no main, no boilerplate — that's Python's philosophy of readability and simplicity.
To run this yourself, save it in a file called hello.py, then in a terminal type:
python hello.pyNow let's make it interactive. This next program asks for your name and greets you, using input() to read what you type and an f-string to slot the name into the message:
name = input("What's your name? ")
print(f"Hello, {name}! Welcome to Python.")Anatomy of a Python program
Even that tiny print line has parts worth naming. Let's dissect it:
print1(2"Hello, World!"3)A function call
print is a built-in function that displays text on the screen.
Parentheses
The ( ) call the function, passing it whatever is inside as an argument.
A string
Text wrapped in quotes — the value we want to print.
Notice what's not there: no class, no main function, no semicolons, no curly braces. Python strips programs down to their essence. But it has one famous rule that surprises newcomers — indentation is part of the syntax. Where other languages use braces to group code, Python uses indentation (spaces at the start of a line). Lines indented the same amount belong to the same block:
if 5 > 2:
print("Five is greater than two") # indented -> inside the if
print("Both of these lines run")
print("This line always runs") # not indented -> outsideIndentation is not optional
IndentationError), not just a style issue. Use a consistent 4 spaces per level — the standard, and what every editor inserts when you press Tab.Comments & docstrings
Comments are notes for humans that Python ignores. Anything after a # on a line is a comment. Python also has docstrings — triple-quoted strings placed at the top of a function, class, or module to document what it does:
# This is a single-line comment — Python ignores it.
x = 5 # comments can also sit at the end of a line
def greet(name):
"""Return a friendly greeting.
Text like this (a docstring) documents what a function does.
"""
return f"Hello, {name}"
print(greet("World"))Tip
The Zen of Python
Python has a famous, slightly playful guiding philosophy. Type import this into the REPL and it prints The Zen of Python — 19 aphorisms that capture how Pythonic code should feel:
import thisThe Zen of Python — a few lines
- Beautiful is better than ugly.
- Simple is better than complex.
- Readability counts.
- There should be one — and preferably only one — obvious way to do it.
- Now is better than never.
Note
Recap & quick check
Key takeaways
- Programming is writing precise, unambiguous instructions a computer can execute.
- Python is compiled to bytecode by CPython, then run by the Python Virtual Machine — the same code runs anywhere.
- Python is high-level, readable, and versatile — huge in data science, web, automation, and more. Always use Python 3.
- print() displays text; input() reads it; f-strings slot values into text.
- Python uses indentation (4 spaces) instead of braces to group code — it's part of the syntax, not just style.
Quick check
1. How does the standard Python (CPython) run your program?
2. What does Python use to group blocks of code?
3. Which function displays text on the screen?
4. Which version of Python should you use today?
5. What is the REPL?
Brilliant — you understand how Python works and you've run your first program. Next up: Module 2 — Variables, Data Types & Operators, where you'll start storing and manipulating real data.