Python practice guides for beginners.
Practical ways to use the lessons: a core study plan, a method for learning from answers, and focused exercise sets for print, loops, lists, tuples, classes, modules, nested data, recursion, regex, generators, decorators, context managers, dataclasses, itertools, collections, functools, enums, CSV, logging, paths, dates, assertions, type hints, HTTP requests, HTML parsing, URLs, pagination, robots.txt, tokenization, softmax, k-NN, model evaluation, prompt validation, linear regression, gradient descent, Naive Bayes, k-means, and model monitoring.
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 ten core lessons…
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. This guide shows a…
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, quotes, and formatt…
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 blank line and…
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, mutation, and the dif…
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 to a list.…
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 behaviour.…
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 each name obvious…
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 fields.…
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 lazy iterators…
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 quantifiers.…
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 and zip put thos…
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 what it means in…
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 choosing the right obj…
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 teaching and test…
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 bug reaches run…
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 when a full list w…
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, caching, and …
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 around a block …
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 what it generat…
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, chain, and groupb…
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 pick a container w…
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 when wrapping a c…
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 lookups become ex…
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 lines by hand.…
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 easier to inspect wi…
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 hitting a live sit…
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 text, then combi…
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 them against th…
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 build each piec…
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 file to the wider …
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 the vocabulary is…
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 exercises build …
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 exercises make each of…
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 compute the confus…
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. These exercis…
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 prediction is outside…
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 show how one bad l…
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 space, and chec…
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 centroid can be ch…
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 enough evidence to a…
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 ceiling, a resume fil…
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 survives the afternoo…