by pythoncompiler.io

ThePythonBook

The Interactive Python Blog Tutorials.

From your first program to machine learning — learn by doing.

111tutorials
649exercises
100%free

Python Fundamentals

Variables, data types, strings, operators, and your first programs

10 tutorials

Python for Beginners: Your First Program in 5 Minutes

Learn Python from scratch. Write your first Python program, understand print(), variables, and basic syntax — all running directly in your browser.

beginner20m460

Python Variables and Data Types: A Practical Introduction

Master Python variables, data types (int, float, str, bool, None), type checking, and type conversion with hands-on examples and exercises.

beginner25m695

Python Numbers: Integers, Floats, and Math You\

Master Python integers, floats, and arithmetic operators. Learn math operations, number conversion, rounding, and real-world calculations with interactive examples.

beginner20m6110

Python Strings: Create, Access, Slice, and Manipulate Text

Learn how to create, access, slice, and manipulate strings in Python. Master indexing, slicing, concatenation, and common string operations with interactive examples.

beginner25m7135

Every Python String Method Explained with Examples

Master Python string methods: upper(), lower(), strip(), split(), join(), replace(), find(), and more. Interactive examples and exercises for every method.

beginner25m6100

Python String Formatting: f-strings, format(), and % Operator

Master Python string formatting with f-strings, .format(), and the % operator. Learn number formatting, alignment, and real-world formatting patterns.

beginner20m575

Python Booleans, Comparisons, and All Operators Explained

Master Python booleans, comparison operators, logical operators (and, or, not), truthiness, and operator precedence with interactive examples.

beginner25m690

Python Input and Output: print(), input(), and Formatting

Master Python print() with sep, end, and formatting. Understand input() for user interaction. Learn output patterns used in real programs.

beginner15m490

Python Type Conversion: How to Convert Between Data Types

Learn implicit and explicit type conversion in Python. Master int(), float(), str(), bool() and avoid common conversion errors.

beginner20m585

Writing Clean Python: Comments, Docstrings, and PEP 8

Learn to write clean, readable Python code. Master comments, docstrings, naming conventions, and PEP 8 style guidelines that professional developers follow.

beginner15m490

Control Flow

If-else, for loops, while loops, and controlling program flow

6 tutorials

Data Structures

Lists, tuples, dictionaries, sets, and complex data handling

10 tutorials

Python Lists: Create, Access, Modify, and Loop Through Lists

Learn everything about Python lists — how to create, access, modify, sort, and loop through them with practical examples and exercises.

beginner30m8145

Python Comprehensions: List, Dict, Set, and Generator in One Guide

Master Python comprehensions — list, dict, set, and generator expressions. Transform loops into elegant one-liners with filtering, mapping, and conditional logic.

intermediate30m8115

Python Tuples: When and Why to Use Immutable Sequences

Master Python tuples — immutable sequences for fixed data. Learn tuple creation, packing, unpacking, indexing, when to use tuples vs lists, and real-world patterns.

beginner20m560

Python Dictionaries: The Complete Guide with Real Examples

Master Python dictionaries — create, access, modify, and loop through key-value pairs. Learn dict methods, nested dicts, and real-world patterns with interactive examples.

beginner30m8110

Python Sets: Unique Collections, Operations, and Use Cases

Master Python sets — unique, unordered collections. Learn set creation, operations (union, intersection, difference), methods, and real-world deduplication patterns.

intermediate20m685

Python Slicing: Master Indexing for Strings, Lists, and Tuples

Master Python slicing with start:stop:step notation. Learn to extract portions of strings, lists, and tuples, reverse sequences, and use negative indices.

beginner20m680

Python Unpacking: Starred Expressions, Swapping, and Destructuring

Master Python unpacking — assign multiple values at once, swap variables, use starred expressions (*), and destructure nested data structures.

intermediate20m570

Python Sorting: sort(), sorted(), Key Functions, and Custom Order

Master Python sorting with sort(), sorted(), reverse parameter, key functions, and lambda-based custom sorting. Learn to sort any data the way you need.

intermediate25m685

Working with Nested Lists, Dicts, and Complex Data Structures

Learn to work with nested Python data: lists of dicts, dicts of lists, JSON-like structures. Master accessing, modifying, and iterating through complex data.

intermediate25m685

Python Copy vs Deepcopy: Why Your 'Copy' Isn\

Understand Python\

intermediate20m570

Functions

Define functions, arguments, scope, recursion, and higher-order functions

6 tutorials

Error Handling

Try-except, custom exceptions, context managers, and logging

4 tutorials

Modules & Packaging

Imports, packages, virtual environments, and publishing to PyPI

4 tutorials

File I/O & Data Formats

Read and write files, CSV, JSON, and pathlib

4 tutorials

Object-Oriented Programming

Classes, inheritance, magic methods, dataclasses, and design patterns

13 tutorials

Python Classes and Objects: OOP from the Ground Up

Learn Python classes and objects from scratch. Understand __init__, self, instance methods, class attributes, and __str__ with interactive examples and exercises.

intermediate30m795

Python Inheritance: Subclasses, Polymorphism, and super()

Master Python inheritance — create subclasses, override methods, use super(), and understand polymorphism with interactive code examples and exercises.

intermediate25m685

Python @classmethod vs @staticmethod: When to Use Each

Learn the difference between @classmethod and @staticmethod in Python. Master factory methods, utility functions, and when to use each decorator with hands-on exercises.

intermediate20m570

Python @property: Getters, Setters, and Computed Attributes

Master Python @property decorator to create getters, setters, deleters, and computed attributes with validation. Learn encapsulation through hands-on exercises.

intermediate20m690

Python Magic Methods: The Complete __dunder__ Guide

Master Python magic methods (dunder methods) including __str__, __repr__, __len__, __eq__, __lt__, __getitem__, __contains__, and __call__ with interactive exercises.

advanced30m8120

Python Operator Overloading: Make Classes Work with +, -, ==

Learn Python operator overloading with __add__, __sub__, __mul__, __eq__, __radd__, and __iadd__. Build custom classes that work with arithmetic and comparison operators.

advanced25m695

Python Abstract Base Classes: Enforce Interfaces with ABC

Learn how to use Python\

advanced25m585

Python Multiple Inheritance and MRO: How It Actually Works

Understand Python multiple inheritance, the diamond problem, Method Resolution Order (MRO), super() in complex hierarchies, and practical mixin patterns.

advanced25m595

Python Dataclasses: Less Boilerplate, More Readable Code

Master Python dataclasses to eliminate repetitive __init__, __repr__, and __eq__ boilerplate. Learn @dataclass, field(), __post_init__, frozen classes, and comparison.

intermediate25m7105

NamedTuple vs TypedDict vs Dataclass: Which to Choose?

Learn when to use NamedTuple, TypedDict, or dataclass in Python. Compare structured data containers with interactive examples and exercises.

intermediate20m570

Python __slots__: Reduce Memory Usage by 40%

Learn how __slots__ works in Python to reduce memory usage and speed up attribute access. Interactive examples with memory comparisons.

advanced20m575

Advanced Dataclasses: __post_init__, frozen, field(), slots, and Inheritance

Master advanced dataclass features including validation with __post_init__, immutability with frozen, complex defaults with field(), and dataclass inheritance patterns.

advanced25m690

Composition vs Inheritance: Why \

Learn when to use composition over inheritance in Python. Understand has-a vs is-a relationships, dependency injection, and how to refactor fragile inheritance hierarchies.

advanced25m580

Testing

pytest, mocking, fixtures, and test-driven development

3 tutorials

Standard Library Essentials

collections, itertools, functools, datetime, regex, and more

7 tutorials

Advanced Python

Iterators, generators, decorators, type hints, async, and internals

12 tutorials

Python Iterators: How for Loops Really Work Under the Hood

Python Iterators: How for Loops Really Work Under the Hood — interactive tutorial with runnable examples and practice exercises.

advanced25m6105

Python Generators: Process Millions of Items Without Running Out of Memory

Python Generators: Process Millions of Items Without Running Out of Memory — interactive tutorial with runnable examples and practice exercises.

advanced30m7125

Python Decorators Explained: A Step-by-Step Guide

Python Decorators Explained: A Step-by-Step Guide — interactive tutorial with runnable examples and practice exercises.

advanced30m8145

Python Type Hints: Add Types, Generics, and the typing Module

Python Type Hints: Add Types, Generics, and the typing Module — interactive tutorial with runnable examples and practice exercises.

intermediate25m695

Python Protocols: Duck Typing with Type Safety

Python Protocols: Duck Typing with Type Safety — interactive tutorial with runnable examples and practice exercises.

advanced25m5100

Python Pydantic: Validate Data Like a Pro

Python Pydantic: Validate Data Like a Pro — interactive tutorial with runnable examples and practice exercises.

advanced25m6120

15 Python Pitfalls That Trip Up Even Experienced Developers

15 Python Pitfalls That Trip Up Even Experienced Developers — interactive tutorial with runnable examples and practice exercises.

intermediate25m7105

Python Threading vs Multiprocessing vs asyncio: When to Use What

Python Threading vs Multiprocessing vs asyncio: When to Use What — interactive tutorial with runnable examples and practice exercises.

advanced30m5100

Python Async/Await: Write Non-Blocking Code from Scratch

Python Async/Await: Write Non-Blocking Code from Scratch — interactive tutorial with runnable examples and practice exercises.

expert30m6120

Python Design Patterns: Factory, Strategy, Observer, and More

Python Design Patterns: Factory, Strategy, Observer, and More — interactive tutorial with runnable examples and practice exercises.

advanced30m6120

How Python Works Under the Hood: Memory, GIL, and Bytecode

How Python Works Under the Hood: Memory, GIL, and Bytecode — interactive tutorial with runnable examples and practice exercises.

expert30m5100

Build Command-Line Tools with argparse and sys.argv

Build Command-Line Tools with argparse and sys.argv — interactive tutorial with runnable examples and practice exercises.

intermediate25m575

Metaprogramming

Metaclasses, descriptors, __new__, and dynamic attribute access

4 tutorials

Data Science & Machine Learning

NumPy, Pandas, Matplotlib, SciPy, and scikit-learn

20 tutorials

NumPy Arrays: Create, Index, Slice, and Reshape

NumPy Arrays: Create, Index, Slice, and Reshape — interactive tutorial with runnable examples and practice exercises.

intermediate30m7105

NumPy Operations: Element-wise Math, Aggregations, and ufuncs

NumPy Operations: Element-wise Math, Aggregations, and ufuncs — interactive tutorial with runnable examples and practice exercises.

intermediate25m690

NumPy Broadcasting: Operate on Arrays of Different Shapes

NumPy Broadcasting: Operate on Arrays of Different Shapes — interactive tutorial with runnable examples and practice exercises.

advanced25m5100

NumPy Linear Algebra: Dot Products, Inverses, and Eigenvalues

NumPy Linear Algebra: Dot Products, Inverses, and Eigenvalues — interactive tutorial with runnable examples and practice exercises.

advanced25m5100

Pandas: Create, Load, and Explore DataFrames

Pandas: Create, Load, and Explore DataFrames — interactive tutorial with runnable examples and practice exercises.

intermediate30m7105

Pandas Indexing: loc, iloc, Boolean Indexing, and Selection

Pandas Indexing: loc, iloc, Boolean Indexing, and Selection — interactive tutorial with runnable examples and practice exercises.

intermediate25m690

Pandas Data Cleaning: Missing Values, Duplicates, and Outliers

Pandas Data Cleaning: Missing Values, Duplicates, and Outliers — interactive tutorial with runnable examples and practice exercises.

intermediate30m7105

Pandas merge(), join(), concat(): Combine DataFrames Like SQL

Pandas merge(), join(), concat(): Combine DataFrames Like SQL — interactive tutorial with runnable examples and practice exercises.

intermediate25m690

Pandas GroupBy: Split-Apply-Combine for Powerful Aggregations

Pandas GroupBy: Split-Apply-Combine for Powerful Aggregations — interactive tutorial with runnable examples and practice exercises.

advanced30m7130

Pandas apply(), map(), transform(): Custom Data Transformations

Pandas apply(), map(), transform(): Custom Data Transformations — interactive tutorial with runnable examples and practice exercises.

advanced25m6110

Pandas String and DateTime Operations for Real-World Data

Pandas String and DateTime Operations for Real-World Data — interactive tutorial with runnable examples and practice exercises.

intermediate25m685

Pandas Pivot Tables and Cross-Tabulation for Business Analysis

Pandas Pivot Tables and Cross-Tabulation for Business Analysis — interactive tutorial with runnable examples and practice exercises.

advanced25m595

Matplotlib: Create Line, Bar, Scatter, and Pie Charts

Matplotlib: Create Line, Bar, Scatter, and Pie Charts — interactive tutorial with runnable examples and practice exercises.

intermediate25m690

Advanced Matplotlib: Subplots, Dual Axes, Styles, Annotations

Advanced Matplotlib: Subplots, Dual Axes, Styles, Annotations — interactive tutorial with runnable examples and practice exercises.

advanced25m5100

Data Visualization: Choose the Right Chart and Tell a Story

Data Visualization: Choose the Right Chart and Tell a Story — interactive tutorial with runnable examples and practice exercises.

advanced25m5100

SciPy Statistics: Distributions, Hypothesis Tests, and Correlations

SciPy Statistics: Distributions, Hypothesis Tests, and Correlations — interactive tutorial with runnable examples and practice exercises.

advanced30m6120

Build Your First ML Model: Linear Regression with scikit-learn

Build Your First ML Model: Linear Regression with scikit-learn — interactive tutorial with runnable examples and practice exercises.

intermediate30m690

Python Classification: Build a Classifier with scikit-learn

Python Classification: Build a Classifier with scikit-learn — interactive tutorial with runnable examples and practice exercises.

intermediate30m690

Evaluating ML Models: Cross-Validation, Metrics, and Overfitting

Evaluating ML Models: Cross-Validation, Metrics, and Overfitting — interactive tutorial with runnable examples and practice exercises.

advanced25m5100

K-Means Clustering: Find Patterns in Data Without Labels

K-Means Clustering: Find Patterns in Data Without Labels — interactive tutorial with runnable examples and practice exercises.

advanced25m5100

Practical Projects

Build real-world projects: pipelines, dashboards, and ML applications

8 tutorials

Build an Automated Data Cleaning Pipeline

Build an Automated Data Cleaning Pipeline — interactive tutorial with runnable examples and practice exercises.

intermediate40m8120

Build a Sales Performance Dashboard with KPI Analysis

Build a Sales Performance Dashboard with KPI Analysis — interactive tutorial with runnable examples and practice exercises.

intermediate40m7105

Build a Budget Tracker and Expense Analyzer

Build a Budget Tracker and Expense Analyzer — interactive tutorial with runnable examples and practice exercises.

intermediate35m690

Build a Log File Parser That Finds Errors and Patterns

Build a Log File Parser That Finds Errors and Patterns — interactive tutorial with runnable examples and practice exercises.

advanced35m6120

Predict Customer Churn: End-to-End Data Analysis (with sklearn)

Predict Customer Churn: End-to-End Data Analysis (with sklearn) — interactive tutorial with runnable examples and practice exercises.

advanced45m7140

Build an Inventory Management System with SQLite

Build an Inventory Management System with SQLite — interactive tutorial with runnable examples and practice exercises.

advanced40m7140

Time Series: Detect Trends and Anomalies in Business Data

Time Series: Detect Trends and Anomalies in Business Data — interactive tutorial with runnable examples and practice exercises.

advanced40m6120

Build a Simple ETL Pipeline: Extract, Transform, Load

Build a Simple ETL Pipeline: Extract, Transform, Load — interactive tutorial with runnable examples and practice exercises.

advanced40m7140