Learn Python – tutorial, cheatsheet & exercises
Python is one of the most popular programming languages in the world. The code reads almost like English, and indentation replaces curly braces, which makes Python ideal for getting started.
At the same time, Python is extremely powerful: data science (pandas, NumPy), machine learning (PyTorch, scikit-learn), web development (Django, Flask, FastAPI) and automation are core areas. A huge ecosystem (PyPI) provides a ready-made package for almost any task.
Hello World in Python
print("Hello World!")print outputs text to the console – no main, no parentheses needed.
How to get started with Python
Install Python from python.org (or with brew install python on a Mac, winget install Python.Python.3 on Windows). Check the installation in the terminal:
python3 --versionStart interactive mode with python3 or run a file:
python3 hallo.pypython3 -m venv .venv and then source .venv/bin/activate. This keeps packages separate for each project.Python learning path
Hello World & print
Your first program and how output works.
Variables & Data Types
Numbers, text, Booleans and how Python handles types.
Conditions: if, elif, else
Making decisions in code.
Loops: for & while
Repeating tasks – over numbers, lists and more.
Functions
Reusable building blocks of code with parameters and return values.
Lists, Tuples, Dictionaries, Sets
The four most important collection types.
Strings & Files
Processing text, reading and writing files.
Error Handling
try/except, custom errors and cleaning up with finally.
Classes & Object-Oriented Programming
Custom data types with data and behavior.
Modules, Packages & pip
Using the standard library and installing packages.
At a glance
More about Python
Test & practice
Interactive quiz, timed exam with certificate, and exercises with an editor: