Chapter One

Introduction: What Is Python?

Learning Objectives
  1. Explain what Python is and how it differs from compiled languages like C and Java
  2. Describe the origins of Python and the design philosophy that shaped it
  3. Identify the major domains where Python is used today
  4. Compare Python with other popular programming languages on key dimensions
  5. Summarise how the Python community governs the language through PEPs and the PSF

If you have ever used a website, trained a machine learning model, automated a tedious spreadsheet task, analysed a dataset, or written a quick script to rename five hundred files at once, there is a very good chance Python was involved. It is, by most measures, the most popular programming language in the world — and it achieved that status not by being the fastest, the most elegant, or the most theoretically pure, but by being the most useful to the most people. Python is the language you reach for when you want to get something done, think clearly about the problem, and not fight the tool while you do it. This book is about learning that language from the ground up.

What Python Is

Python is a general-purpose, high-level programming language. That sentence contains three ideas worth unpacking.

General-purpose means Python is not tied to a single domain. Unlike R, which was built for statistics, or SQL, which was built for databases, Python is designed to do almost anything: build websites, crunch numbers, control robots, write games, automate system administration, and much more. Whether it is the best tool for every one of those jobs is debatable; that it is a good tool for all of them is not.

High-level means you work with concepts close to human thinking — lists, strings, dictionaries, functions — rather than the raw memory addresses and register allocations that a language like C demands. Python manages memory for you, handles type conversions where sensible, and generally tries to stay out of your way.

Programming language means it is a formal system for expressing computation: a set of rules for writing instructions that a computer can execute. Python instructions look remarkably like English pseudocode, which is one of the reasons it is so widely used in education.

name = "Ada"
if len(name) > 3:
    print(f"Hello, {name}!")

That snippet is valid Python. If you can roughly guess what it does, you already understand one of the language's central virtues: readability.

A Brief History

Python was created by Guido van Rossum, a Dutch programmer who began writing it over the Christmas holidays of 1989 at Centrum Wiskunde & Informatica (CWI) in Amsterdam. He was frustrated with the limitations of ABC, an educational language he had helped develop, and wanted something that kept ABC's clean syntax but was extensible enough for real-world programming. The first public release, version 0.9.0, appeared in February 1991 — the same year Linus Torvalds posted his famous message about a little operating system he was building.

The name has nothing to do with snakes. Van Rossum was a fan of Monty Python's Flying Circus, and he wanted a name that was short, slightly irreverent, and easy to remember. The tradition stuck: Python documentation is littered with references to spam, eggs, knights who say Ni, and dead parrots.

Van Rossum guided the language for nearly thirty years under the informal title BDFL — Benevolent Dictator for Life. He stepped down from the role in 2018 after a contentious debate about assignment expressions (the walrus operator, :=), and governance passed to a five-member Steering Council elected by core developers. The language continues to evolve at a steady pace, with a new minor version released every October.

The Zen of Python

Every design decision in Python traces back, directly or indirectly, to a set of principles captured in a document called The Zen of Python, written by Tim Peters in 1999. You can read it at any time by opening a Python interpreter and typing import this. A few of the most important aphorisms:

  • Beautiful is better than ugly. Code should be pleasant to read.
  • Explicit is better than implicit. Do not hide what the code is doing.
  • Simple is better than complex. If a simpler solution exists, prefer it.
  • Readability counts. Code is read far more often than it is written.
  • There should be one — and preferably only one — obvious way to do it. Reduce the number of choices a programmer must make.

These are not enforced by the compiler, but they are enforced by the culture. Python code that violates them will work, but it will earn disapproving looks in code reviews.

The practical consequence of this philosophy is a language with an unusually strong emphasis on convention. Python has an official style guide, PEP 8, that specifies everything from indentation width (four spaces) to how to name your variables (snake_case, not camelCase). Most Python developers follow it, most tools enforce it, and the result is that Python code written by different people tends to look surprisingly similar.

Where Python Is Used

The breadth of Python's adoption is staggering, and it continues to expand.

Web development was one of Python's early strengths. Frameworks like Django and Flask power websites from Instagram to Pinterest to Mozilla. The language's clean syntax makes web backends readable, and its enormous ecosystem of libraries handles everything from authentication to payment processing.

Data science and machine learning is where Python truly exploded in the 2010s. Libraries like NumPy, pandas, scikit-learn, TensorFlow, and PyTorch made Python the lingua franca of quantitative research. Most AI papers published today include Python code.

Automation and scripting is Python's quiet superpower. System administrators, DevOps engineers, and anyone who has ever thought "I could automate this" reaches for Python. It replaces shell scripts that have grown too complex, glues together APIs, and turns manual workflows into reproducible pipelines.

Scientific computing relies on Python across physics, biology, chemistry, astronomy, and medicine. The SciPy ecosystem, Matplotlib for visualisation, and Jupyter notebooks for interactive exploration have made Python the default language of research computing.

Education is where many people encounter Python first. Its gentle learning curve and readable syntax make it the most popular language for introductory computer science courses worldwide. If you are learning to program in 2026, you are probably learning Python.

Python 2 vs Python 3

For over a decade, the Python community was split between two incompatible versions of the language. Python 2, released in 2000, and Python 3, released in 2008, differed in subtle but breaking ways: how strings handled Unicode, how division worked, how print was called. The migration was painful, slow, and sometimes bitter.

That era is over. Python 2 reached its official end of life on 1 January 2020. No security patches, no bug fixes, no support of any kind. Every major library has dropped Python 2 compatibility. Every new project uses Python 3. This book uses Python 3 exclusively, and you should too. If you encounter Python 2 code in the wild, treat it as legacy that needs migrating, not a style to emulate.

How Python Runs

When you run a Python script, several things happen under the surface. Python is an interpreted language, which means you do not compile it into machine code the way you would with C or Rust. Instead, the standard Python implementation — called CPython, because it is written in C — reads your source code, compiles it into an intermediate form called bytecode, and then executes that bytecode on a virtual machine.

source.py  →  bytecode (.pyc)  →  CPython VM  →  result

This is why Python is slower than C for raw computation: there is an extra layer of interpretation between your code and the hardware. But it is also why Python is so flexible — the interpreter can inspect and modify running code, handle types dynamically, and provide the interactive experience that makes the REPL so pleasant.

CPython is not the only implementation. PyPy uses just-in-time compilation to run Python code much faster. MicroPython runs on microcontrollers with kilobytes of RAM. Jython runs on the Java Virtual Machine, and IronPython on .NET. But CPython is the reference implementation, the one you get when you type python3, and the one this book assumes.

Comparison with Other Languages

Python occupies a particular niche in the programming language landscape, and understanding that niche helps you know when to use it and when to reach for something else.

Compared with C, Python is dramatically easier to write and dramatically slower to execute. C gives you direct control over memory and hardware; Python gives you productivity and safety. Many Python libraries — NumPy, for example — are actually written in C underneath, giving you the best of both worlds: Python's interface with C's speed.

Compared with Java, Python is more concise and less ceremonious. Java requires classes, type declarations, and boilerplate that Python simply does not. Java compiles to bytecode that runs on the JVM, which is generally faster than CPython but less convenient for quick scripting.

Compared with JavaScript, Python is more consistent and more readable, but JavaScript owns the browser. If you are building a web frontend, you need JavaScript (or TypeScript). For everything else — backends, data analysis, automation, scientific computing — Python is usually the better choice.

Compared with R, Python is a general-purpose language that happens to be good at statistics, while R is a statistics language that can be coerced into general-purpose work. For pure statistical analysis, R has deeper roots; for anything that involves building a pipeline, deploying a model, or writing production code, Python wins.

The Python Community

Python is developed in the open, governed by a process that is remarkably transparent for a project of its size. The Python Software Foundation (PSF) is the non-profit organisation that holds the intellectual property, funds development, and organises PyCon, the annual conference that draws thousands of developers from around the world.

Language changes go through Python Enhancement Proposals, or PEPs. A PEP is a design document — part specification, part argument — that must survive review by the core development team before it is accepted. PEP 8 (the style guide), PEP 20 (The Zen of Python), and PEP 484 (type hints) are among the most influential. The process is slow and deliberate, which is why Python evolves steadily rather than lurching between paradigms.

The broader community is enormous and, for the most part, welcoming. PyPI, the Python Package Index, hosts over 500,000 packages. Stack Overflow has millions of answered Python questions. Real Python, Talk Python, and countless blogs and podcasts cater to every level from absolute beginner to language internals specialist.

Python is not just a language. It is an ecosystem, a community, and — like Linux — a culture with its own traditions, heroes, and gentle in-jokes. The chapters ahead will teach you the language. The community will teach you the rest.