Python

A readable, general-purpose language for scripts, data and the web.

Python is a high-level, dynamically typed language known for its clean, readable syntax. It is used for data analysis, machine learning, web backends and everyday automation, which makes it a good first language.

  • Beginner
  • 34 lessons
  • 47 exercises
  • Runs in your browser
Not started yet0 of 47 exercises solved
Start lesson 1

Lessons

  1. Hello, World!Your first program prints a line of text. It confirms Python is installed correctly and shows you how to run a script.2 exercises
  2. Variables & Data TypesVariables store values so you can use them later. Python is dynamically typed, so you don't declare a type: it works it out from the value you assign.2 exercises
  3. Control FlowConditions and loops let your program make decisions and repeat work. In Python, indentation (not curly braces) marks which lines belong to each block.3 exercises
  4. FunctionsFunctions are named, reusable blocks of code. They let you write logic once, call it from many places, and change it in one spot.3 exercises
  5. Lists, Dicts & SetsLists, dictionaries and sets are Python's built-in ways to hold groups of values. Between them they cover most everyday data-handling needs.3 exercises
  6. Modules & PackagesModules let you split code across files and reuse code other people have written. Python ships with a large standard library, and PyPI hosts hundreds of thousands of extra packages.2 exercises
  7. Error HandlingPrograms run into problems: missing files, bad input, failed network requests. try/except lets you handle those errors instead of letting the program crash.3 exercises
  8. Mini Project: CLI Todo AppIn this project you build a command-line todo app that saves tasks to a file. It brings together everything from the earlier lessons.1 exercise
  9. Classes & OOPClasses let you bundle data and the functions that work on it into your own types. Python classes are lighter than those in Java or C++: no access modifiers and no header files.2 exercises
  10. File I/OReading and writing files is how programs keep data between runs. The "with" statement opens a file and closes it again automatically, even if an error occurs.2 exercises
  11. Comprehensions & GeneratorsComprehensions build a new list, dict or set from an existing one in a single line. Use them for simple transformations and switch to a regular loop when the logic gets complicated.2 exercises
  12. Decorators & Functional ToolsA decorator is a function that takes a function and returns a new one, and the @ syntax is shorthand for applying it. Decorators work because functions in Python are ordinary objects.3 exercises
  13. Type Hints & Modern PythonType hints label what kind of value a variable or function expects. Python ignores them at runtime, but tools like mypy use them to catch bugs before you run the code, and they make your code easier to read.2 exercises
  14. Iterators & GeneratorsA list holds every element in memory at once; a generator produces elements one at a time, on demand. That lets you work through very large files or endless sequences using very little memory.3 exercises
  15. Async & ConcurrencyMany programs spend most of their time waiting on the network, the disk or a database. asyncio lets one thread run many of those waits at the same time, so ten one-second requests take about one second instead of ten.1 exercise
  16. Testing, Virtual Environments & PackagingTests let you change code with confidence. This lesson covers the tools around a real Python project: virtual environments, pytest, and a pyproject.toml that makes your code installable.1 exercise
  17. Strings, DeeplyMost real programs are mostly string handling: parsing, cleaning, formatting, searching. Python's str type is small, immutable and full of well-named methods worth knowing by heart.2 exercises
  18. Regular ExpressionsA regular expression is a tiny language for describing text patterns. Learn a dozen symbols and you can validate, extract and rewrite text that would take pages of if-statements.2 exercises
  19. Working with JSONJSON is the common format of APIs, config files and data exports. Python's json module turns it into dicts and lists and back again in one call each.2 exercises
  20. collections & itertoolsTwo standard-library modules that turn ten-line loops into one-liners: collections for smarter containers, itertools for smarter iteration.2 exercises
  21. RecursionA recursive function calls itself on a smaller piece of the problem until the piece is trivial. It is the natural way to handle trees, nested data and anything defined in terms of itself.2 exercises
  22. Debugging & Reading TracebacksPrograms fail. The skill that separates beginners from professionals is not avoiding errors but reading them calmly and finding the cause fast.2 exercises
  23. Python Package Field GuidePyPI has hundreds of thousands of packages. This guide points you to the ones worth learning first and what each is good for.
  24. Subprocess & System AutomationPython can run the other programs on your computer. The subprocess module is the standard, safe way to call command-line tools from Python.
  25. Tkinter Desktop AppsTkinter ships with most Python installations and turns a script into a real window. It is a good fit for small utilities, internal tools, and learning event-driven programming.
  26. Paramiko: SSH & SFTPParamiko lets Python securely run commands and transfer files over SSH. Use it for systems you own or are explicitly authorized to administer.
  27. Requests, HTTP & APIsMost useful programs eventually talk to another service. Requests makes HTTP readable while still exposing the timeouts, headers, status codes, and sessions that reliable clients need.
  28. Pandas: Practical Data AnalysisPandas lets you load, clean and analyse tables of data in code. It is useful when a spreadsheet task gets repetitive but a database would be more than you need.
  29. Build Polished CLIs with Typer & RichA good command-line app has help text, validation, readable errors, and useful output. Typer and Rich supply those details without burying your actual program.
  30. FastAPI & Pydantic: Build an APIFastAPI combines type hints, validation, async support, and automatic documentation. Pydantic turns untrusted JSON into validated Python objects.
  31. SQLAlchemy: Python & DatabasesSQLAlchemy maps Python objects to relational data while still letting you use the power of SQL. Start with SQLite locally; move to PostgreSQL when deployment needs it.
  32. Pillow: Image AutomationPillow is the practical toolkit for resizing, cropping, converting, compositing, and inspecting images. A short script can replace a lot of repetitive manual editing.
  33. OpenPyXL: Automate ExcelOpenPyXL reads and writes modern Excel workbooks. Use it for reports that people need to open, filter, print and share.
  34. Python CheatsheetThe whole language on one page — syntax, collections, idioms. Bookmark this.

Install it on your own computer

Python ships pre-installed on macOS and most Linux distros. On Windows you install it yourself, which takes a few minutes. You do not need this to follow the lessons: the examples run in your browser.

Bash
# Option 1: Official installer (recommended)
# Visit python.org/downloads, download the latest 3.x installer
# CRITICAL: Check "Add Python to PATH" before clicking Install

# Verify in terminal:
python --version    # or python3 --version

# Option 2: Microsoft Store
# Search "Python 3.12" in the Microsoft Store, click Get

# Option 3: winget
winget install Python.Python.3

What people build with Python

Learn the basics first, then pick up these tools when a project needs them.

Practical uses

  • Automate files, spreadsheets, and repetitive office work
  • Build APIs, web backends, and internal tools
  • Analyze data and train machine-learning models
  • Write scientific simulations and test infrastructure

Projects to try

  1. CLI habit tracker
  2. CSV expense analyzer
  3. FastAPI book catalog
  4. Image classifier with a small web UI

Common tools and packages

DjangoFastAPIFlaskpandasNumPyPyTorchpytestRuff

Well-known software

InstagramDropboxBlenderAnsibleJupyterCalibre