A young woman with braided hair working on a laptop at her desk

Track · Beginner

Python Essentials

The language of AI, data science and data engineering.

Start from zero and learn the whole language: values, control flow, every built-in collection, functions in depth, generators, files, the standard library, object-oriented programming and professional habits. It's the foundation the Data Science, Data Engineering and AI & ML tracks all build on.

Modules
11
Labs
44
Projects
3
Activities
432

Plus an optional bonus module, Your developer toolkit, that opens when you finish.

The journey

11 modules, one skill at a time, plus a bonus

  1. 1

    First steps

    5 labs

    Your first programs

  2. 2

    Lists & loops

    4 labs

    Code that scales to any amount of data

  3. 3

    Sequences & text

    4 labs

    Fluent with sequences and text

  4. 4

    Collections

    6 labs

    The right container every time

  5. 5

    Functions

    6 labs

    Functions, fully

  6. 6

    Iterators & generators

    2 labs

    Lazy, efficient iteration

  7. 7

    Errors & files

    5 labs

    Real data, from file to answer

  8. 8

    The standard library

    3 labs

    Batteries included

  9. 9

    Object-oriented programming

    5 labs

    Objects of your own

  10. 10

    Professional Python

    3 labs

    Code you can trust

  11. 11

    Capstone project

    1 lab

    Python Essentials — complete

  12. 12Bonus

    Your developer toolkit

    5 labs

    A developer's setup

What you'll build

4 projects from real local data

Syllabus

Every module and lab

  • Lesson
  • Interactive
  • Quiz
  • Trace
  • Puzzle
  • Find the bug
  • Scenario
  • Practice
  • Challenge
  • Reflect
01

First steps

Values, numbers, text, input and decisions: the building blocks of every program.

5 labs · 48 activities

  • Lab 01 · Python basics

    Values & Variables

    Make Python do arithmetic on market prices, store results in well-named variables, read error messages, and learn the one difference that trips up every beginner: numbers vs text.

    25 min10 activities
  • Lab 02 · int, float and operators

    Numbers & Arithmetic

    Weigh, pack and price a harvest with Python's arithmetic: whole numbers and decimals, three different ways to divide, rounding, and the surprising reason 0.1 + 0.2 isn't 0.3.

    30 min9 activities
  • Lab 03 · str, input() and types

    Text, Input & Conversion

    Write text Python can't misread, read what a user types with input(), and turn it into numbers safely: the first thing every program that talks to people has to get right.

    30 min10 activities
  • Lab 04 · Conditions

    Making Decisions

    Teach your code to choose: compare values, branch with if/elif/else, nest one decision inside another, pick between two values in one line, and build the simplest classifier there is, a threshold rule.

    30 min10 activities
  • Lab 05 · bool, None and truthiness

    Truth, None & Logic

    Every value in Python counts as either true or false, missing data is None, and and and or do more than you'd think. Learn the rules behind conditions that read like plain English, and the bug that treats zero as missing.

    30 min9 activities

Milestone 1

Your first programs

You can store values, calculate with numbers and text, read what a user types, and make decisions with conditions.

02

Lists & loops

One name for many values, and code that repeats for every one of them.

4 labs · 43 activities

  • Lab 06 · Lists & slicing

    Lists: Many Values, One Name

    A dataset is many values in order. Store them in lists, reach any item by position, slice out ranges, change lists with every method they have, and build tables out of lists of lists.

    40 min12 activities
  • Lab 07 · for loops

    Loops: Do It For Every Item

    Real datasets have thousands of rows. Loops let you run the same instructions for every item: to total, average, convert, filter and count, to count with range, and to walk every cell of a table.

    40 min12 activities
  • Lab 08 · Loops that wait for a condition

    while, break & continue

    Some loops can't know in advance how many times they'll run: saving until you reach a target, retrying until a payment goes through, asking until the PIN is right. Learn while, break, continue and the loop's else.

    35 min10 activities
  • Lab 09 · enumerate, zip and key functions

    Looping Like a Pro

    Python's built-in helpers make loops shorter and safer: number items with enumerate, walk lists side by side with zip, sort and pick the best by any rule with key=, and ask any() or all() about a whole list at once.

    35 min9 activities

Milestone 2

Code that scales to any amount of data

You can hold a column of data and total, count, filter or search it with loops of every kind.

03

Sequences & text

How Python stores values, tuples and unpacking, and text from messy input to polished output.

4 labs · 39 activities

  • Lab 10 · Names, objects and mutation

    References & Copies

    Why changing one list can change another, what is really asks, and how to copy a list, or a list of lists, safely. It's the mental model behind a huge share of Python bugs.

    35 min10 activities
  • Lab 11 · Fixed groups of values

    Tuples & Unpacking

    A tuple is a list that can't change: just right for a record like a GPS point or a (name, price) pair. Pack and unpack values, swap two variables in one line, grab "the rest" with *, and give your records names with namedtuple.

    30 min9 activities
  • Lab 12 · Cleaning, searching, testing and joining text

    Strings in Depth

    Most real data arrives as messy text: names with stray spaces, phone numbers in five formats, amounts buried in SMS messages. Learn to clean, search, test, slice, split and join text, and pull numbers out of it.

    40 min11 activities
  • Lab 13 · f-string formats, repr and str

    Formatting Output

    Numbers people can read at a glance: money with thousands separators, percentages, signed changes, aligned columns for receipts and reports, and the repr that shows you exactly what a value is when you're debugging.

    35 min9 activities

Milestone 3

Fluent with sequences and text

You know what a variable really points at, and you can clean, slice, split and format any text.

04

Collections

Dictionaries, sets, comprehensions, the collections module and pattern matching.

6 labs · 52 activities

  • Lab 14 · Dicts & records

    Dictionaries: Data With Labels

    Look values up by name instead of position. A dictionary is one row of data; a list of dictionaries is a whole dataset. Learn every dictionary method, nested dictionaries, grouping, and finding the key with the biggest value.

    40 min12 activities
  • Lab 15 · Unique values and fast membership

    Sets

    A set holds each value only once, answers "is it in there?" instantly, and compares whole groups: who paid both months, who paid at all, who still owes. It's the tool for deduplicating and reconciling lists.

    30 min7 activities
  • Lab 16 · List, dict and set comprehensions

    Comprehensions

    Build a whole list, dictionary or set in one readable line: transform every item, keep only the ones you want, choose between two values, and flatten a table. And learn when a plain loop reads better.

    35 min9 activities
  • Lab 17 · Counter, defaultdict and deque

    The collections Module

    The standard library has power tools for jobs you've been doing by hand: Counter counts anything in one line, defaultdict starts every group for you, and deque makes a fast queue and a sliding window.

    30 min8 activities
  • Lab 18 · match and case

    Pattern Matching with match

    match compares a value against patterns and runs the first one that fits: menu choices, commands typed as text, and records of different shapes. When the shape of the data decides what happens next, it's clearer than a long if/elif chain.

    35 min9 activities
  • Project · Collections project

    Chama Contributions Ledger

    A women's savings group in Nakuru has four months of payments typed into a phone, and arguments about who owes what. Clean the records, settle the arrears, check the merry-go-round was fair and work out the fines.

    45 min7 activities

Milestone 4

The right container every time

You can choose and use lists, tuples, dicts and sets, build them with comprehensions, and match on their shape.

05

Functions

From your first def to arguments, scope, closures, recursion and decorators.

6 labs · 66 activities

  • Lab 19 · def & return

    Functions: Reusable Recipes

    Package logic into named, reusable functions: parameters in, a return value out. Return early, return several values at once, document what a function does, and discover that a trained model is really just a function.

    35 min11 activities
  • Lab 20 · Defaults, keywords, *args, **kwargs

    Arguments in Depth

    Make functions flexible and safe to call: default values, keyword arguments, any number of arguments with *args and **kwargs, keyword-only parameters, and the mutable-default trap that catches everyone once.

    40 min11 activities
  • Lab 21 · LEGB, global, nonlocal, closures

    Scope & Closures

    Where does Python look when it meets a name? Learn the LEGB rule, why assigning inside a function makes a new local, when global and nonlocal are needed, and how inner functions can remember values: closures.

    40 min11 activities
  • Lab 22 · lambda, key=, map, filter, functools

    Functions as Values

    In Python a function is a value like any other: store it in a variable or a dictionary, pass it to another function, return it. Sort and rank with key=, write quick lambdas, and meet map, filter, functools.partial and reduce.

    40 min11 activities
  • Lab 23 · Base cases and the call stack

    Recursion

    A function that calls itself can solve a problem by solving a smaller copy of it. Learn base cases, watch the call stack grow and shrink, walk nested data like folders and organisation charts, and know when a loop is the better tool.

    40 min11 activities
  • Lab 24 · Wrapping functions with @

    Decorators

    A decorator wraps a function to add behaviour around it, such as logging, counting, checking or caching, without touching the function's own code. Build your own with closures, use the @ syntax and functools.wraps, and speed up recursion with functools.cache.

    40 min11 activities

Milestone 5

Functions, fully

You can design functions with flexible arguments, reason about scope, and use closures, recursion and decorators.

06

Iterators & generators

What really happens in a for loop, and data that's produced only when it's needed.

2 labs · 21 activities

  • Lab 25 · iter, next, yield

    Iterators & Generators

    What really happens in a for loop: iterables, iterators, iter() and next(). Then write generators with yield, which produce values one at a time, only when they're needed, so you can process streams of data of any size.

    40 min10 activities
  • Lab 26 · The iteration toolkit

    itertools

    The standard library's toolkit for iterators: endless counters, joining and slicing streams, running totals, grouping, and every pairing or combination of a set of items. Questions about balances, fixtures and sales by market take a line or two.

    35 min11 activities

Milestone 6

Lazy, efficient iteration

You can write generators and combine iterators to process data streams of any size.

07

Errors & files

Handling what goes wrong, cleaning up reliably, and reading and writing real data.

5 labs · 48 activities

  • Lab 27 · try, except, else, finally, raise

    Errors & Exceptions

    Real data will break your code. Catch errors without crashing, handle different errors differently, clean up with finally, raise clear errors of your own, and define new kinds of error for your own programs.

    40 min11 activities
  • Lab 28 · CSV files

    Reading Real Data

    Real data lives in files. Open a CSV of market prices, turn every row into a dictionary, convert the text to numbers, and answer questions with it.

    30 min8 activities
  • Lab 29 · open modes, pathlib, csv.writer

    Writing Files & Folders

    Programs don't just read data, they save it: reports, logs and cleaned datasets. Write and append to text files, handle paths and folders with pathlib, write CSV files any spreadsheet can open, and automate tidying a messy downloads folder.

    40 min10 activities
  • Lab 30 · with, and writing your own

    Context Managers

    with guarantees clean-up: files closed, settings restored and half-finished changes undone, even when something goes wrong. See what with really does, use ready-made context managers, and write your own with @contextmanager and a generator.

    35 min9 activities
  • Lab 31 · json, nested data, APIs

    JSON & APIs

    JSON is the format almost every web API speaks. Convert between JSON text and Python, find your way around nested responses, write JSON files, and check data from an API before you trust it, using a week of Kisumu weather.

    40 min10 activities

Milestone 7

Real data, from file to answer

You can read and write CSV, JSON and text files, survive bad data, and raise clear errors of your own.

08

The standard library

Organising code into modules, and the batteries Python ships with.

3 labs · 30 activities

  • Lab 32 · import, your own modules, __main__

    Modules & Packages

    Every .py file is a module. Import in all its forms, use a module and a package written by someone else, find out what happens the first time a module is imported, and make your own files importable with if __name__ == "__main__":.

    35 min10 activities
  • Lab 33 · datetime, timedelta, time zones

    Dates & Times

    Dates are everywhere in real data: due dates, transaction times, planting seasons. Create and compare dates, do arithmetic with timedelta, parse and format dates in any layout, and handle time zones properly.

    40 min10 activities
  • Lab 34 · re: patterns in text

    Regular Expressions

    Find and pull out patterns in messy text: phone numbers, transaction codes, amounts and dates in mobile-money messages. Learn the pattern language, use re.search, re.findall, re.sub and groups, validate formats, and know when plain string methods are clearer.

    40 min10 activities

Milestone 8

Batteries included

You can split a program into modules and reach for the standard library before writing code yourself.

09

Object-oriented programming

Classes and objects, inheritance, special methods, properties and dataclasses.

5 labs · 47 activities

  • Lab 35 · class, self, methods

    Classes & Objects

    Design your own types: a class bundles data with the methods that work on it. Create objects, understand self, share data with class attributes, protect an object's data with checks, and build a tiny model with the same interface as scikit-learn.

    40 min11 activities
  • Lab 36 · subclasses, super(), has-a

    Inheritance & Composition

    Build new classes from existing ones. A subclass inherits everything and changes only what's different, super() reuses the parent's code, and different objects can answer the same method in their own way. When "has a" fits better than "is a", build objects out of other objects instead.

    40 min9 activities
  • Lab 37 · __repr__, __eq__, __len__ and friends

    Special Methods

    Make your objects behave like Python's own types: print readably, compare with == and <, sort, add up with +, and work with len(), in, indexing and for loops. Special methods, the ones named with double underscores, are how.

    40 min10 activities
  • Lab 38 · @property, @classmethod, @dataclass, Enum

    Properties, Class Methods & Dataclasses

    The tools that make classes pleasant to write and to use: properties that compute or check values behind plain attribute syntax, class methods as extra constructors, dataclasses that write __init__, __repr__ and __eq__ for you, and enums for fixed sets of choices.

    40 min10 activities
  • Project · Objects project

    Mobile-Money Wallet

    Build a small mobile-money system out of objects: wallets that keep their own history, transactions as frozen dataclasses, an enum of transaction types, a family of custom errors, and a network that moves money between phones without ever losing a shilling.

    50 min7 activities

Milestone 9

Objects of your own

You can design classes that work like Python's own types, the way libraries such as scikit-learn are built.

10

Professional Python

Finding bugs, proving code works, type hints, clean code, and async.

3 labs · 31 activities

  • Lab 39 · tracebacks, assert, pytest, logging

    Debugging & Testing

    The most useful programming skill nobody teaches: finding bugs systematically. Read tracebacks, step through code, write tests that prove your code works, run them with pytest, and replace stray prints with proper logging.

    45 min11 activities
  • Lab 40 · annotations, PEP 8, refactoring

    Type Hints & Clean Code

    Write Python other people can read and trust: type hints that say what goes in and comes out (so tools can catch mistakes before the code runs), the PEP 8 style every Python programmer follows, good names, and refactoring messy code without changing what it does.

    40 min9 activities
  • Lab 41 · async, await, asyncio

    Async & Concurrency

    Programs spend most of their time waiting: for a network, a database, a file. async and await let Python get on with other work while it waits, so ten slow requests take about as long as one. Write coroutines, run them together with asyncio.gather, limit how many run at once, handle timeouts and failures, and know when threads or processes are the better tool.

    45 min11 activities

Milestone 10

Code you can trust

You can debug methodically, test your code, and write Python other people can read and maintain.

11

Capstone project

Put it all together on a real question with messy data.

1 lab · 7 activities

  • Project · Capstone

    Maize Price Tracker

    A farmers' cooperative in Kisumu asks: where and when should we sell our maize? Load a year of messy market data into typed records with real dates, analyse it with well-named, tested functions, forecast next month's price, and deliver a JSON report and a recommendation.

    60 min7 activities

Milestone 11

Python Essentials — complete

You've taken messy data all the way to a defensible recommendation. You're ready for Data Science, Data Engineering or AI & ML.

12
Optional bonus · doesn't count towards finishing the track

Your developer toolkit

Leave the browser: Python on your own computer, packages and virtual environments, notebooks, Git and GitHub.

5 labs · 38 activities

  • Lab 42 · Editors, terminals and scripts

    Python on Your Computer

    So far Python has run in your browser. Real projects run on your own machine: install Python and VS Code, find your way around a terminal, and turn code into scripts that take commands and work with files.

    40 min8 activities
  • Lab 43 · pip, versions and requirements

    Packages & Virtual Environments

    Python's power is its packages — pandas, scikit-learn and hundreds of thousands more. Install them the way professionals do: one virtual environment per project, versions pinned, requirements written down.

    35 min8 activities
  • Lab 44 · The data scientist's lab book

    Notebooks: Jupyter & Colab

    Most data and AI work starts in a notebook — Jupyter on your laptop, or Google Colab and Kaggle in the cloud. Learn how notebooks work, avoid their most common trap, and open a real notebook in Colab.

    35 min8 activities
  • Lab 45 · Version control

    Git & GitHub

    Every professional codebase lives in Git, and most are shared on GitHub. Learn commits, branches and merges, see how Git fingerprints your files — by computing it yourself — and keep secrets out of your history.

    45 min8 activities
  • Project · Capstone

    Ship Your Project

    Turn the Maize Price Tracker into a real project someone else can download and run: a command-line tool, a README, pinned requirements, a .gitignore and tests — then put it on your own GitHub.

    60 min6 activities

Milestone 12

A developer's setup

You can run Python on your own machine, manage packages and notebooks like a developer, and have a tested project on your GitHub.