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.
# a tiny first program price = 4.5 quantity = 3 print(f"Total: ${price * quantity:.2f}")
Fifty lessons, in the order that clicks.
Each lesson is short enough for one sitting. Practice immediately after, while the idea is still fresh.
Python Print and Strings
Make Python show text, combine values, and format messages you can actually read.
Python Variables and Types
Store values in named variables and learn how Python decides what kind of value you have.
Python String Methods
Clean, split, join, and inspect text with the string methods you will use every day.
Python If, Elif, and Else
Make programs choose between paths with comparisons and boolean logic.
Python For Loops
Repeat work over a collection and build totals without writing the same line again.
Python Lists
Keep an ordered collection, change it safely, and pull out the parts you need.
Python Dictionaries
Store labelled values and look them up by name instead of by position.
Python Functions
Package a calculation once, give it a name, and reuse it without copying code.
Python Error Handling
Catch predictable failures, show a useful fallback, and keep the program running.
Python JSON for Beginners
Turn JSON text into Python values, inspect nested records, and send data back as JSON.
Python while Loops
Repeat work until a condition changes, and know when to stop.
Python Tuples and Sets
Choose a fixed record or a unique collection, and use each one deliberately.
Python List Comprehensions
Build a new collection from an old one without writing a long loop.
Python Sorting and Key Functions
Put data in order by the field you actually care about.
Python Classes and Objects
Group data and the functions that work on it into a small, reusable object.
Python Modules and Imports
Use code that already exists instead of rebuilding it.
Python Nested Data
Work with JSON-like data one level at a time.
Python Lambda, map, and filter
Write short functions and transform sequences without a loop.
Python Recursion
Solve a problem by calling a smaller version of itself.
Python Regular Expressions
Find and replace text patterns without writing a manual parser.
Python enumerate and zip
Add positions and pair sequences without manual counters.
Python Paths with pathlib
Treat file paths as objects instead of fragile strings.
Python Dates and Times with datetime
Work with calendar dates and simple durations accurately.
Python Testing with assert
Turn expected behavior into checks you can run again.
Python Type Hints
Make the shape of your data visible to readers and tools.
Python Generators
Produce values lazily instead of building a full list.
Python Decorators
Wrap a function with reusable behavior without editing its body.
Python Context Managers
Guarantee setup and cleanup with a with block.
Python Dataclasses
Declare data-focused classes without repetitive boilerplate.
Python itertools
Compose lazy iterators for counting, chaining, and grouping.
Python collections
Reach for the right container instead of rebuilding it by hand.
Python functools
Reuse function behavior with caching, partial application, and reduction.
Python Enums
Name a fixed set of values once and use the names everywhere.
Python CSV Files
Read and write tabular text without splitting lines by hand.
Python Logging
Record what happened with levels, handlers, and formats.
Python HTTP requests for scraping
Build a polite request before you parse a single tag.
Python HTML parsing
Let a parser track HTML structure instead of guessing with regex.
Python URL parsing
Resolve relative links correctly before they enter the crawl queue.
Python pagination and deduplication
A crawl is a queue with a memory and a budget.
Python robots.txt and polite scraping
Permission, limits, and privacy are part of the scraper.
Python tokens and text vectors
Turn text into tokens, then compare documents as vectors.
Python softmax and temperature
Turn raw scores into a probability distribution without overflow.
Python nearest-neighbor classifier
Classify a point by looking at the neighbors it resembles.
Python model evaluation and accuracy
A score is only useful when you know what it measured.
Python prompt templates and structured output
Treat model output as untrusted input, not as finished data.
Python linear regression from scratch
Fit a line, make a prediction, and measure how wrong it is.
Python gradient descent, step by step
Follow the gradient downhill and watch the learning rate matter.
Python Naive Bayes text classifier
Classify short texts with counts, priors, and smoothing.
Python k-means clustering from scratch
Assign points, move centroids, and repeat until stable.
Python model monitoring and drift checks
Compare live behavior with a baseline before users notice.
“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
A practice loop, not a content treadmill.
You can finish a lesson in ten minutes and still have time to try the questions.
One idea at a time
Short explanations with code you can run and change. No installation and no wall of syntax.
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.
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.
Guides for the questions beginners actually ask.
Use these when you want a practice plan, a study method, or a focused set of exercises.
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 smarterPython 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 focusPython 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 focusPython 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 focusPython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 practicePython 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 walkthroughBatch 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 walkthroughLocal 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…
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.
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.