Python15 min readBeginner

Hello, Python

What Python is, how to install it, and how to run your very first program.

What is Python?

Python is a high-level, general-purpose programming language created by Guido van Rossum in 1991. "High-level" means the language hides the messy hardware details — you don't manage memory by hand, you don't worry about pointers, you just describe what you want the computer to do.

Python is also interpreted. That means your code is executed line-by-line by a program called the Python interpreter, instead of being compiled into a standalone binary. The upside: you can run a script the moment you save it. The downside: it's slower than compiled languages like C or Rust — but for almost everything except heavy numerical loops, you won't notice.

Python is famous for its readability. Whitespace is significant — instead of curly braces, you use indentation to mark blocks. This forces every Python program to look roughly the same, which makes other people's code easier to read.

Where Python is used

  • Web backends (Django, Flask, FastAPI) — Instagram and Reddit run on Python.
  • Data science and machine learning (NumPy, Pandas, PyTorch, TensorFlow).
  • Automation and scripting — anything from renaming files in bulk to scraping websites.
  • DevOps and infrastructure (Ansible, SaltStack).
  • Education — it is the most common first language taught in universities.

Installing Python

On Windows: download the installer from python.org and tick the box that says "Add Python to PATH". On macOS: install Homebrew and run `brew install python`. On Linux: it's almost always already installed, but you can run `sudo apt install python3` to be sure. Verify your install by opening a terminal and running:

bash
python --version
# or, on some systems:
python3 --version

You should see something like `Python 3.12.x`. Anything 3.10 or higher is fine for everything in this book.

Your first program

The traditional first program in any language is one that prints "Hello, world!". In Python, it is exactly one line:

print("Hello, world!")

Let's break that down. `print` is a built-in function — a piece of code shipped with Python that you can call by name. The parentheses tell Python you're calling the function. The text inside the quotes is a string, which is just Python's word for a piece of text. The function takes that string and writes it to your terminal, followed by a newline.

💡 Tip
Open the Playground (top right) and run this code right now. You'll learn ten times faster by typing things yourself than by reading them.

Variables

A variable is a name that points to a value. You create one with `=` (the assignment operator):

name = "Ada"
age = 36
print(f"{name} is {age} years old")
🏷️
Real-life analogy — A variable is a luggage tag
The variable name is a tag tied to a suitcase. The suitcase (the value) lives somewhere in the storage room (memory). When you assign a new value to the variable, you're not modifying the suitcase — you're moving the tag to a different one.
How variables actually live in memory
name
"Ada"
age
36
Each variable name (left) is a label that POINTS TO a value stored in memory (right). Reassigning a variable doesn't move the value — it just re-points the label.

Notice the `f` before the second string. That makes it an f-string (formatted string), and anything inside curly braces gets evaluated and inserted into the string. F-strings were added in Python 3.6 and they are by far the cleanest way to build strings out of variables.

  • Variables are labels that point to values stored in memory.
  • Python is dynamically typed: you don't declare a type up front. The type is whatever you happen to assign.
  • Variable names are case-sensitive: `Name` and `name` are different.
  • Use snake_case for variables and functions (lowercase, words separated by underscores).
  • Names must start with a letter or underscore, and can't be one of Python's reserved keywords (like `if`, `for`, `class`).

Comments

Anything after a `#` on a line is a comment — Python ignores it. Comments are notes for human readers. Use them to explain WHY something is done, not WHAT (the code already shows the what).

# This is a comment
radius = 5  # in centimeters
area = 3.14159 * radius * radius
Which is the correct way to print in Python 3?
What kind of typing does Python use?