Python, one small win at a time

Learn Python by doing, not watching.

Fifty short lessons. 600 lesson questions plus a 3,000-question full bank. Clear explanations after every attempt. No account, no setup, no video queue.

Free to use. Progress stays in this browser. Code runs in your browser.

50short lessons
3,600practice questions
3answer formats
first_script.py
# a tiny first program
price = 4.5
quantity = 3
print(f"Total: ${price * quantity:.2f}")
▶ run in browser Python 3
try it yourself
The path

Fifty lessons, in the order that clicks.

Each lesson is short enough for one sitting. Practice immediately after, while the idea is still fresh.

01

Python Print and Strings

Make Python show text, combine values, and format messages you can actually read.

Beginner18 min read12 questions
02

Python Variables and Types

Store values in named variables and learn how Python decides what kind of value you have.

Beginner18 min read12 questions
03

Python String Methods

Clean, split, join, and inspect text with the string methods you will use every day.

Beginner18 min read12 questions
04

Python If, Elif, and Else

Make programs choose between paths with comparisons and boolean logic.

Beginner18 min read12 questions
05

Python For Loops

Repeat work over a collection and build totals without writing the same line again.

Beginner19 min read12 questions
06

Python Lists

Keep an ordered collection, change it safely, and pull out the parts you need.

Beginner18 min read12 questions
07

Python Dictionaries

Store labelled values and look them up by name instead of by position.

Beginner19 min read12 questions
08

Python Functions

Package a calculation once, give it a name, and reuse it without copying code.

Beginner19 min read12 questions
09

Python Error Handling

Catch predictable failures, show a useful fallback, and keep the program running.

Beginner19 min read12 questions
10

Python JSON for Beginners

Turn JSON text into Python values, inspect nested records, and send data back as JSON.

Beginner18 min read12 questions
11

Python while Loops

Repeat work until a condition changes, and know when to stop.

Beginner19 min read12 questions
12

Python Tuples and Sets

Choose a fixed record or a unique collection, and use each one deliberately.

Beginner18 min read12 questions
13

Python List Comprehensions

Build a new collection from an old one without writing a long loop.

Beginner18 min read12 questions
14

Python Sorting and Key Functions

Put data in order by the field you actually care about.

Beginner19 min read12 questions
15

Python Classes and Objects

Group data and the functions that work on it into a small, reusable object.

Beginner19 min read12 questions
16

Python Modules and Imports

Use code that already exists instead of rebuilding it.

Intermediate18 min read12 questions
17

Python Nested Data

Work with JSON-like data one level at a time.

Intermediate19 min read12 questions
18

Python Lambda, map, and filter

Write short functions and transform sequences without a loop.

Intermediate18 min read12 questions
19

Python Recursion

Solve a problem by calling a smaller version of itself.

Intermediate20 min read12 questions
20

Python Regular Expressions

Find and replace text patterns without writing a manual parser.

Intermediate20 min read12 questions
21

Python enumerate and zip

Add positions and pair sequences without manual counters.

Intermediate18 min read12 questions
22

Python Paths with pathlib

Treat file paths as objects instead of fragile strings.

Intermediate19 min read12 questions
23

Python Dates and Times with datetime

Work with calendar dates and simple durations accurately.

Intermediate19 min read12 questions
24

Python Testing with assert

Turn expected behavior into checks you can run again.

Intermediate18 min read12 questions
25

Python Type Hints

Make the shape of your data visible to readers and tools.

Intermediate19 min read12 questions
26

Python Generators

Produce values lazily instead of building a full list.

Intermediate20 min read12 questions
27

Python Decorators

Wrap a function with reusable behavior without editing its body.

Intermediate20 min read12 questions
28

Python Context Managers

Guarantee setup and cleanup with a with block.

Intermediate20 min read12 questions
29

Python Dataclasses

Declare data-focused classes without repetitive boilerplate.

Intermediate19 min read12 questions
30

Python itertools

Compose lazy iterators for counting, chaining, and grouping.

Intermediate20 min read12 questions
31

Python collections

Reach for the right container instead of rebuilding it by hand.

Intermediate19 min read12 questions
32

Python functools

Reuse function behavior with caching, partial application, and reduction.

Intermediate19 min read12 questions
33

Python Enums

Name a fixed set of values once and use the names everywhere.

Intermediate18 min read12 questions
34

Python CSV Files

Read and write tabular text without splitting lines by hand.

Intermediate19 min read12 questions
35

Python Logging

Record what happened with levels, handlers, and formats.

Intermediate19 min read12 questions
36

Python HTTP requests for scraping

Build a polite request before you parse a single tag.

Practical19 min read12 questions
37

Python HTML parsing

Let a parser track HTML structure instead of guessing with regex.

Practical18 min read12 questions
38

Python URL parsing

Resolve relative links correctly before they enter the crawl queue.

Practical18 min read12 questions
39

Python pagination and deduplication

A crawl is a queue with a memory and a budget.

Practical19 min read12 questions
40

Python robots.txt and polite scraping

Permission, limits, and privacy are part of the scraper.

Practical19 min read12 questions
41

Python tokens and text vectors

Turn text into tokens, then compare documents as vectors.

Foundations19 min read12 questions
42

Python softmax and temperature

Turn raw scores into a probability distribution without overflow.

Foundations18 min read12 questions
43

Python nearest-neighbor classifier

Classify a point by looking at the neighbors it resembles.

Practical19 min read12 questions
44

Python model evaluation and accuracy

A score is only useful when you know what it measured.

Practical19 min read12 questions
45

Python prompt templates and structured output

Treat model output as untrusted input, not as finished data.

Practical20 min read12 questions
46

Python linear regression from scratch

Fit a line, make a prediction, and measure how wrong it is.

Applied19 min read12 questions
47

Python gradient descent, step by step

Follow the gradient downhill and watch the learning rate matter.

Applied19 min read12 questions
48

Python Naive Bayes text classifier

Classify short texts with counts, priors, and smoothing.

Applied19 min read12 questions
49

Python k-means clustering from scratch

Assign points, move centroids, and repeat until stable.

Applied19 min read12 questions
50

Python model monitoring and drift checks

Compare live behavior with a baseline before users notice.

Applied19 min read12 questions
“The best way to learn Python is to write a little, predict what will happen, and find out why you were wrong.”

PyPractice method
attempt → check → explain → retry

How it works

A practice loop, not a content treadmill.

You can finish a lesson in ten minutes and still have time to try the questions.

01 / READ

One idea at a time

Short explanations with code you can run and change. No installation and no wall of syntax.

02 / ANSWER

Three ways to recall

Choose an answer, fill the missing code, or predict the exact output. Each format tests a different part of your understanding.

03 / ADJUST

Read the reason

Correct answers are not the end. The explanation tells you which rule mattered, so the next attempt is a little more deliberate.

Go deeper

Guides for the questions beginners actually ask.

Use these when you want a practice plan, a study method, or a focused set of exercises.

Start here

Python Practice for Beginners: A Simple 4-Week Plan

Most beginners do not need more videos. They need a small number of concepts, repeated until they can use them without looking. This plan turns the first t…

Practice smarter

Python Exercises With Answers: How to Practice Without Copying

An answer is useful only after you have tried the problem. If you read the solution first, you can recognise it later without being able to produce it. Thi…

Lesson focus

Python Print Exercises for Beginners

print() looks simple, but it is the fastest way to inspect a program. These exercises cover the details beginners trip over: separators, line endings, quot…

Lesson focus

Python Loop Exercises: Five Patterns That Cover Most Beginner Problems

Most beginner loop problems are variations of five patterns. Learn to recognise the pattern first, then write the loop. That is faster than starting from a…

Lesson focus

Python List Exercises for Beginners

Lists are the first data structure most beginners use, and small misunderstandings cause most of the bugs. These exercises focus on indexes, slices, mutati…

Focused practice

Python while Loop Exercises: 5 Patterns That Cover Most Problems

Most while-loop exercises are variations on five patterns. Once you can name the pattern, you can write the condition and the update without guessing.…

Focused practice

Python Tuple and Set Exercises: Fixed Records and Unique Values

Tuples and sets solve two different problems: keeping a fixed record, and keeping only unique values. Practice choosing between them instead of defaulting …

Focused practice

Python List Comprehension Exercises: Map, Filter, and Build

A comprehension is a compact way to build a collection. The useful question is not “Can I shorten this?” but “Does the transformation stay obvious?”…

Focused practice

Python Sorting Exercises: key, reverse, and Record Order

Sorting a list of numbers is only the first step. The useful skill is sorting records by a chosen field while keeping the original data intact.…

Focused practice

Python Class Exercises: Build a Small Object Model

Classes become easier when you start with one small record. Build an object that stores a few fields, add one method, and test it before adding more behavi…

Focused practice

Python Import Exercises: Modules, Aliases, and the Standard Library

Imports are a small piece of syntax with a large payoff: they let you use tested code instead of rebuilding every tool. The key is to make the source of ea…

Focused practice

Python Nested Data Exercises: Lists of Dictionaries

Nested data looks complicated until you name each level. A list of dictionaries is just a collection of records; each dictionary is one record with named f…

Focused practice

Python Lambda, map, and filter Exercises

map and filter are short tools for transforming and selecting values. They are easiest to use when the function is simple and you remember that both return…

Focused practice

Python Recursion Exercises: Base Cases and Smaller Problems

Recursion is easier when you write the stopping condition first. Then ask one question: what smaller input can this function pass to itself?…

Focused practice

Python Regex Exercises: Search, Find, and Replace

Regular expressions are a compact language for text patterns. Start with one clear pattern, test it on a small string, and only then add groups or quantifi…

Focused practice

Python enumerate and zip Exercises: Cleaner Loops

Most loop bugs come from bookkeeping: an index that drifts, a counter that starts at the wrong place, or two lists that silently stop matching. enumerate a…

Focused practice

Python pathlib Exercises: Paths, Names, and Text Files

A path is more than a string. It has a parent, a name, a suffix, and a platform-specific separator. pathlib gives those ideas names, so your code can say w…

Focused practice

Python datetime Exercises: Dates, Deltas, and Formatting

Dates look simple until month lengths, leap years, and time zones appear. The datetime module handles the calendar rules for you. The main skill is choosin…

Focused practice

Python assert Exercises: Testing Functions with Assertions

An assertion is a claim about your program. When the claim is false, Python raises AssertionError and stops the current path. That makes assert a useful te…

Focused practice

Python Type Hints Exercises: Annotations That Help Readers

Type hints are a communication tool. They tell a reader what a function expects and returns, and they give editors enough information to warn you before a …

Focused practice

Python Generators Practice Guide: Lazy Values

Generators are less about a new syntax trick and more about a different execution model: produce a value, pause, and resume later. That model is useful whe…

Focused practice

Python Decorators Practice Guide: Wrappers

Decorators are a small idea with a large payoff: a function can be passed to another function and replaced by the result. Once that clicks, logging, timing…

Focused practice

Python Context Manager Practice Guide

Cleanup is easy to forget on the success path and even easier to miss when an exception interrupts the function. A context manager puts setup and teardown …

Focused practice

Python Dataclass Practice Guide: Fields

A dataclass is a compact way to say that a class is mostly data. It generates the repetitive methods, but it is still a normal Python class. Understanding …

Focused practice

Python itertools Practice Guide: Lazy Streams

itertools is a toolbox for small iterator operations. The functions do not try to solve a whole problem; they compose. Once you recognize count, islice, ch…

Focused practice

Python collections Exercises: Count, Group, and Queue

The collections module is a set of small tools that remove boilerplate. Instead of writing a counting loop, a missing-key check, or a manual queue, you pic…

Focused practice

Python functools Exercises: Cache, Partial, Reduce

functools is about adapting functions without rewriting them. You can cache expensive results, freeze an argument, fold a sequence, or preserve metadata wh…

Focused practice

Python Enum Exercises: Names, Values, and Lookup

An enum gives a fixed set of names to a concept such as status, color, or direction. The members are real objects, not loose strings, so comparisons and lo…

Focused practice

Python CSV Exercises: Read, Write, and Quote

CSV looks like plain text until a comma appears inside a field. The csv module handles quoting, delimiters, and row boundaries so you do not have to split …

Focused practice

Python Logging Exercises: Levels, Handlers, Format

Print statements disappear when you need context. Logging gives each message a severity, a destination, and a format, which makes production behavior easie…

Focused practice

Python Web Scraping Exercises: Build a Polite Pipeline

A scraper is a pipeline, not a single request. These exercises separate fetching, parsing, extracting, and storing so every stage can be tested without hit…

Focused practice

Python HTMLParser Exercises: Links, Text, and Attributes

A parser is easier to trust when you build it in small handlers. These exercises add one responsibility at a time: collect tags, read attributes, capture t…

Focused practice

Python URL Parsing Exercises: Join, Query, and Clean

Most duplicate links are not really duplicates; they are the same destination written four ways. These exercises turn URL strings into components, resolve …

Focused practice

Python Pagination Exercises: Queues, Visits, and Limits

Pagination is a graph walk with a budget. A queue decides what comes next, a visited set prevents loops, and a limit keeps the run finite. These exercises …

Focused practice

Python robots.txt Exercises: Rules, Delays, and Ethics

robots.txt is a small text file with large consequences. These exercises parse the common directives, explain longest-match precedence, and connect the fil…

Focused practice

Python Tokenization Exercises: Tokens, Vectors, Cosine

Tokenization is the first place where an AI pipeline can quietly lose information. These exercises make the choices visible: what counts as a token, how th…

Focused practice

Python Softmax Exercises: Stability, Temperature, Log Loss

Softmax looks like two lines of arithmetic, but the details matter: overflow, temperature, and the difference between a probability and a decision. These e…

Focused practice

Python k-NN Exercises: Distance, Votes, and Scaling

k-NN is a good first classifier because every decision is visible. You can inspect the distance, the neighbors, the vote, and the evaluation. These exercis…

Focused practice

Python Model Evaluation Exercises: Beyond Accuracy

Evaluation is where a model meets a decision. A single accuracy number can hide a classifier that never finds the class you care about. These exercises com…

Focused practice

Python Prompt Validation Exercises: JSON, Schemas, Safety

The model is only one part of an AI feature. The surrounding Python decides what goes in, what shape comes out, and what happens when the response is wrong…

Focused practice

Python Linear Regression Exercises: Fit, Predict, Evaluate

These exercises keep linear regression small enough to inspect by hand. You will fit a line, measure its error against a baseline, and decide when a predic…

Focused practice

Python Gradient Descent Exercises: Loss, Steps, Learning Rate

Gradient descent is easier to trust when every step is visible. These exercises isolate the loss, the gradient, the update, and the stopping rule, then sho…

Focused practice

Python Naive Bayes Exercises: Counts, Priors, Smoothing

A Naive Bayes classifier is mostly careful counting. These exercises build the count tables, turn them into smoothed probabilities, compare classes in log …

Focused practice

Python k-Means Exercises: Assign, Update, Measure

k-means becomes less mysterious when assignment, update, and evaluation are separate exercises. These examples use tiny two-dimensional points so every cen…

Focused practice

Python Model Monitoring Exercises: Drift and Alerts

Monitoring is a set of small comparisons, not a dashboard full of numbers. These exercises build a baseline, measure a shift, decide whether there is enoug…

Project walkthrough

Batch AI Jobs in Python: Queue, Retry, Resume, and Cost

A batch job is not a for loop around an API call. This walkthrough builds the four parts that keep a long run honest: stable job keys, a concurrency ceilin…

Project walkthrough

Local LLM Deployment with Python: Ollama, VRAM, and a Real Endpoint

A local model is a process with a memory budget and a latency profile, not a magic box. This walkthrough covers the decisions that decide whether it surviv…

First project

Turn the basics into one working program.

Parse a small receipt, catch bad rows, and print a JSON total. Five short milestones, starter code, and acceptance checks.

Build the receipt parser
FAQ

Before you start.

Do I need an account?

No. Every lesson and practice question works without sign-up. Your solved-question progress is stored in your browser's local storage.

Is the code run on a server?

Lesson code runs in your browser using Pyodide, a Python runtime compiled to WebAssembly. The first run downloads the runtime from a CDN, so it needs an internet connection.

How many questions are there?

The site includes 600 lesson questions plus a separate 3,000-question full bank. The lesson path has four multiple-choice, four fill-in-the-blank, and four output-prediction questions for each of the fifty lessons.

Are answers included?

Yes. Every question has a short explanation. Lesson-bank output answers are executed by the build script before publication; the full bank retains the answers from the original checked bank.

Your first question is waiting.

Start with print and strings, or jump straight into mixed practice.

Practice now