Fifty short Python lessons.
Start at the top if you are new. Fifty lessons follow one coffee cart, from the first hand-written receipt to a model that watches its own drift. Each lesson ends with a runnable example and twelve practice questions.
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.