Hands-on Python: Complete Video Course & Book

From Processor Fundamentals to OOP, Data Structures & Typing

A complete Python course as IDE-style videos, plus a written companion built from the same scripts. 22 modules, 98 lessons, five to ten minutes each.

Beginner · 11 hours · 98 lessons · 694 labs

Who it is for

Beginner level.

For anyone who wants to learn to program, starting from nothing: career changers, analysts, testers and students. You learn what a program is before you write your first one.

What you don't need yet:

What helps:

Before you start:

Take next:

Learning paths:

Nobody needs to know everything before they start. Each course builds on the one before, so a learning path takes you there step by step.

Labs

694 labs, 302 of them graded: you write the code, it runs, and graded labs check the result. The outline lists each lesson's labs.

What is free

Start free: First module free with an account. Pro: Every course, lab, handbook, practice exam and certificate.

Course outline

Before You Write Code

  1. What A Program Really Is (3 labs): You can say what a program is, explain why a computer understands only its own instruction set, trace the path from machine code through assembly to a high level language, and describe the difference between source code on disk and a program running in memory.
  2. How Python Runs Your Code (2 labs): You can explain what a high level language is, what the Python interpreter does with your instructions, and why Python is the language you are learning first.
  3. What Python Is, And Where It Came From (4 labs): You can describe what kind of language Python is, place its origin and the two versus three split in time, read a Python version number, and ask your own interpreter which version, platform and implementation you are running.
  4. Editors, IDEs And Shells (3 labs): You can tell a terminal, a shell and a Python shell apart, choose between an interactive shell, an editor with a terminal, and an IDE for a given piece of work, and say what Idle gives you and when to move on from it.

Install Python Properly

  1. Installing Python On Windows (11 labs): You can install Python on Windows from python.org with the PATH box ticked, verify it in a fresh command prompt with both py and python, and recognise and fix the Microsoft Store stub message.
  2. Installing Python On A Mac (10 labs): You can install your own Python on a Mac by either the python.org installer or Homebrew, leave Apple's system python3 untouched, put yours first on PATH from your zsh profile, and confirm the result with python3 and idle3.
  3. Installing Python On Linux (10 labs): You can add the Python pieces your Linux distribution leaves out with apt, dnf or pacman, understand why pip refuses to install into the system Python, answer that refusal with a virtual environment, and verify the result with python3 and pip3.
  4. Where Python Lives: PATH And Versions (8 labs): You can explain how a command name becomes a program on disk, tell python, python3 and py apart on any of the three operating systems, and ask an interpreter for its own path, version and module search path.
  5. First Run, And Fixing A Broken Install (11 labs): You can run Python three ways - the shell, a file from a terminal and a file from Idle - and diagnose the six failures that break a fresh install by naming the symptom, the cause and the fix.
  6. Your Python Folder And A First Program (3 labs): You can set up a blank-free Python folder, unzip the tutorial's Python 3 examples into it, and run madlib.py on Windows, Mac or Linux.

Meet Idle And The Shell

  1. A Sample Program, Explained (5 labs): You can read madlib.py from top to bottom and say what each line contributes, from the shebang and the documentation string to the format string, the two definitions and the two calls that start everything.
  2. Idle And The Python Shell (1 lab): You can start Idle, tell the Edit window from the Python Shell window, open a shell from the Run menu, and read a shell transcript, knowing which lines you typed and which the computer answered.
  3. Types And Functions, A Whirlwind Tour (6 labs): You can name four kinds of Python data, call a function with none, one or several parameters, ask type and len about a value, convert between numbers and strings, and re-enter an earlier shell line in Idle.

Data And Expressions

  1. Integer Arithmetic And Precedence (5 labs): You can evaluate integer arithmetic at the Python shell, predict the result from the normal rules of precedence, and recognise a continuation line when a parenthesis is left open.
  2. Division, Quotients And Remainders (5 labs): You can choose between true division, floor division and the remainder operator, predict the result of each, and explain why Python's floor division rounds down even when an operand is negative.
  3. Strings, Delimiters And Concatenation (6 labs): You can write string literals with either delimiter, tell a string of digits from an integer, concatenate and repeat strings, and fix the type error that mixing the two produces.
  4. Variables And Assignment (8 labs): You can write assignment statements, explain why the right hand side is evaluated first, and tell a syntax error apart from a name error found while a line is running.
  5. Literals, Identifiers And Keywords (6 labs): You can tell a literal from an identifier, say which character sequences Python allows as a name, avoid the reserved words, and name multi word variables in a conventional way.
  6. The Print Function And String Literals (6 labs): You can display anything you like with the print function, write a string literal that spans several lines, and read the escape codes that stand for a newline, a quote or a backslash.

Programs, Input, Output

  1. The Idle Editor And Running Programs (5 labs): You can open, write, save and run a Python program file in the Idle editor, and you can tell program code apart from Shell text.
  2. Input, And Numbers Versus Digits (10 labs): You can read a line from the user with the input function, and convert a string of digits into a number so that arithmetic works instead of concatenation.
  3. The String Format Method (10 labs): You can build a string with the format method, substituting values into replacement fields by position, repeating a field, and showing a literal brace.

Functions

  1. Defining Your First Function (5 labs): You can write a function definition with def, an indented body and a call, and explain why defining a function is not the same as running it.
  2. Several Functions, And Flow Of Control (6 labs): You can put several function definitions in one file, predict the order in which the lines are executed, and see how indentation decides what is remembered and what is run.
  3. Function Parameters (5 labs): You can write a function with a parameter, call it with different arguments, and explain how a formal parameter is given the value of an actual parameter at the moment of the call.
  4. Multiple Parameters (3 labs): You can define and call a function with several parameters, and explain how the arguments are matched to the parameter names from left to right.
  5. Returning Values (7 labs): You can write a function that returns a value, use a call inside a larger expression, and tell the difference between a function that prints and a function that returns.
  6. Local Scope And Global Constants (6 labs): You can explain why a variable created inside a function is invisible outside it, pass data between functions with parameters, and use a global constant in capitals where a global variable would be wrong.

Dictionaries And Loops

  1. Dictionaries (6 labs): You can create a dictionary, add entries to it, look values up by key, recognise the KeyError a missing key raises, and test for a key with in.
  2. Dictionaries And String Formatting (7 labs): You can build strings with the format method and a dictionary unpacked by two stars, and use locals or an f-string to drop local variable values straight into a format string.
  3. Lists, Range And The For Loop (10 labs): You can update a variable, write a list, generate a sequence with range, and read or write a basic for loop that walks over a list.
  4. Repeat Loops And Successive Modification (11 labs): You can write a simple repeat loop whose loop variable you never use, and build a loop that modifies a variable of your own on every pass, tracing its value pass by pass.
  5. Accumulation Loops (7 labs): You can build a loop that accumulates a result, choose the right initial value for the accumulator, and recognise from an English description when a loop through a sequence is needed.
  6. Playing Computer (7 labs): You can trace a loop or a nest of function calls by hand, keeping one table row per executed line, and use that table to locate the exact line where a logical error appears.
  7. The Print Function Keyword End (7 labs): You can use the print function's end keyword parameter, alone or together with sep, to print several things on one line from inside a loop and still finish the line properly.

Numbers In Depth

  1. Floats, Division And Mixed Types (7 labs): You can predict whether an arithmetic expression produces an int or a float, explain why floating point results are approximations, and write code that never depends on two floats being exactly equal.
  2. Exponents, Roots And Float Formats (10 labs): You can raise numbers to powers, take square roots with a fractional exponent or with the math module, and round a float for display with the format function or a format string, without changing the value itself.
  3. Chapter One In One Sitting (10 labs): You can recall, in one sitting, every idea from chapter one: the types and their literals, variables, operators and precedence, strings and formatting, input and output, functions, dictionaries, loops and floats.

Objects And Methods

  1. Objects, Methods And String Case (6 labs): You can call a method on a string with the object dot method syntax, explain why a string method returns a new string instead of changing the original, and use upper, lower, capitalize, title and count.
  2. String Indices (6 labs): You can pick any character out of a string by index, count either from the front starting at zero or from the right end starting at minus one, and say why an index equal to the length raises IndexError.
  3. String Slices (11 labs): You can take a slice of a string or list with either bound omitted or negative, predict its length, use find to locate a substring, and drive indices and slices from a loop variable.
  4. Split And Join (6 labs): You can cut a string into a list of parts with split, with or without a separator, glue a sequence of strings back together with join, and use the pair in sequence to rewrite a phrase.
  5. Appending To Lists, Sets, Constructors (12 labs): You can grow a list with append inside a loop, explain why that differs from concatenation, build a set to remove duplicates, and recognise a type name used as a constructor.

Mad Libs Revisited

  1. Mad Libs Revisited: Finding The Cues (9 labs): You can write a function that scans a format string and returns the list of cues embedded in it, and you can follow the creative process that produced it.
  2. Mad Libs Revisited: The Whole Program (6 labs): You can read the revised mad lib program function by function, explain why getKeys returns a set, and name the creative problem solving steps that produced it.

Graphics

  1. A Graphics Introduction (10 labs): You can open a graphics window, construct points, circles, lines and rectangles, colour them, draw them, move them and close the window, and you know why the vertical axis points the wrong way.
  2. Sample Graphics Programs (10 labs): You can write a complete graphics program with the standard starting lines, build a picture from circles, lines, ovals, text and polygons, take input from mouse clicks, and close the window from inside the picture.
  3. Reading The graphics.py Documentation (7 labs): You can find any graphics method for yourself in the reference, by knowing whether it belongs to every graphics object, to one particular type, or to the window, and you know the additions this tutorial makes to Zelle's package.
  4. Mutable Objects And Aliases (7 labs): You can explain why assigning one name from another gives two names for a single object, predict when mutating through one name is visible through the other, and use clone or a full slice to get a genuinely separate object.
  5. Animation: Moving One Shape (5 labs): You can animate a single graphics object with a loop, a call to move and a call to time.sleep, explain why the delay and the drawing order matter, and turn a repeated animation loop into a reusable function.
  6. Animation: Loops, Bouncing, Flushing (8 labs): You can animate a group of shapes held in a list, move them diagonally and repeatedly with nested loops, build a shape group at any position by cloning points, and use autoflush with update to get one clean frame per step.
  7. Entry Objects (8 labs): You can put an Entry box in a graphics window with its own label, use a mouse click as the signal that typing has finished, and read or set its contents with getText and setText, converting to numbers where you need them.
  8. Colours, Custom And Random (4 labs): You can use the many built-in colour names, build a colour of your own from red, green and blue intensities with color_rgb, and choose random values from a range with the random module's randrange function.

Files And Chapter Review

  1. Files: Writing And Reading (6 labs): You can open a file for writing or reading, write strings to it with explicit newlines, read the whole file back as one string, and say why closing a file you wrote to is essential.
  2. Chapter Two In One Sitting (9 labs): You can name every object, method and technique chapter two introduced, and say which section to return to for any of them that you cannot yet explain.

Flow Of Control

  1. Conditions And Simple If Statements (7 labs): You can write a condition, say whether it is True or False, and use a simple if statement to run a block of code only when the condition holds.
  2. If Else, And Conditional Expressions (10 labs): You can choose between two blocks of code with an if else statement, write any of the six comparisons correctly, and test membership in a sequence with in and not in.
  3. If Elif Chains (5 labs): You can write an if elif else chain to sort a value into any number of cases, and explain why only the first true test matters.
  4. Nesting Control Flow Statements (9 labs): You can nest if statements inside loops and loops inside if statements, and read the indentation to see which block belongs to which heading.
  5. Compound Boolean Expressions (13 labs): You can build conditions with and, or and not, read their precedence and short circuit behaviour, and return a Boolean expression directly instead of wrapping it in an if else.
  6. More String Methods (7 labs): You can test what a string starts with, ends with or is made of, and build up conditions from string methods such as startswith, endswith, replace and isdigit.
  7. Loops And Tuples (12 labs): You can package related values in a tuple, unpack a tuple in a for loop heading, and replace a long repetitive if elif statement with a loop over a list of tuples.

While Loops

  1. While Loops, And The General Range (8 labs): You can write a while loop whose condition is tested before every pass, spot a loop that will never stop, and use the three argument range function to replace a counting while loop with a for loop.
  2. Interactive While Loops (6 labs): You can write a while loop that reads input until a sentinel value arrives, initialising the test data before the loop and resetting it at the end of the body so the loop can stop.
  3. Graphical Applications With While (12 labs): You can drive an interactive graphics program with a while loop, decide where to cut a repeating pattern into a loop body, and use checkMouse so an animation continues until the user clicks.
  4. Any Type As A Condition (10 labs): You can say which values of any type Python treats as False, use the Pythonic test for an empty collection, and recognise the bugs that arise when a comparison and an or are combined carelessly.
  5. Chapter Three In One Sitting (10 labs): You can recall the whole of chapter three in one pass: comparisons, the three shapes of an if statement, nesting, the Boolean operators, tuples, while loops, the three argument range, and how any value is read as True or False.

Dynamic Web Pages

  1. How A Web Page Reaches You (4 labs): You can explain what a browser and a web server do for each other, read the tags in a simple HTML page, and say which kind of file in this chapter is edited and tested in which way.
  2. Composing Web Pages In Python (8 labs): You can write a Python program that reads a template page from a file, formats your data into it, writes the result out and opens it in your browser.
  3. CGI: Dynamic Web Pages (9 labs): You can start the local Python web server, read the small CGI scripts the tutorial builds up, and say which of the three places an error will show itself in.
  4. HTML Forms And Dynamic Programs (7 labs): You can read and edit an HTML form, make its field names match the names your CGI script asks for, and recognise the text, submit, radio, checkbox and hidden input tags.
  5. Chapter Four In One Sitting (3 labs): You can recite the order of work for building a dynamic web page, and say what each piece of markup, each cgi module call and each error location is for.

Reading Errors, And Platform Notes

  1. Reading Error Messages (7 labs): You can tell a syntax error from a run time error, read a traceback from the bottom up, and follow the chain of calls above the failing line to your own code.
  2. Windows And Mac Specifics (2 labs): You can install Python correctly on your own platform, open and save files ending in dot cgi from Idle, and get the local server and the graphics windows behaving on Windows or on a Mac.

Errors, Exceptions And Debugging

  1. Exceptions: try, except, else, finally (9 labs): You can wrap risky work in a try statement, catch the particular exception it may raise, use the as clause, else and finally correctly, and keep a program alive through bad input.
  2. Raising, And Writing Your Own Exception (6 labs): You can raise a built-in exception with a useful message to refuse bad input, re-raise after logging, chain one exception to another, and define a small exception class of your own when the situation calls for it.
  3. Reading A Traceback Like A Professional (7 labs): You can read a multi-frame traceback bottom up, tell your own frames from a library's, recognise the errors that arrive before execution starts, and name the likely cause behind each of the common exception types.
  4. Debugging: print, breakpoint, and the debugger (6 labs): You can debug a wrong answer deliberately: label your printing, stop a program with breakpoint, step through it with the pdb commands that matter, read the state instead of guessing, and choose between a debugger and a test.

Organising Code

  1. Modules And The Import System (8 labs): You can split code across files with import, explain what happens the first time a module is imported, protect a file's own test code with the main guard, and say where Python looked to find a module.
  2. Packages, And Your Own Library (8 labs): You can lay out a project as a package of modules with a script beside it, import between those modules with absolute imports, and run any module inside the package with the dash m switch.
  3. Virtual Environments (6 labs): You can create a virtual environment for a project, activate and deactivate it on your own operating system, explain what activation does to PATH, and check from inside Python whether you are in one.
  4. pip, requirements, and installing packages (7 labs): You can install, inspect and remove packages with pip inside an activated environment, pin them in a requirements file that rebuilds the environment anywhere, and read the externally managed environment error correctly.

Data Structures In Depth

  1. Lists, Tuples, Sets, Dicts: Choosing One (6 labs): You can choose between a list, a tuple, a set and a dictionary for a given job, say what each costs to search, and explain why a tuple can be a dictionary key when a list cannot.
  2. Comprehensions (7 labs): You can turn a build-a-list loop into a list comprehension with an optional filter, write dictionary and set comprehensions, and say when a plain loop is the clearer choice.
  3. Sorting, Keys And Lambdas (7 labs): You can sort anything by any rule using sorted with a key function, write a lambda for that key, and use stability to sort by two rules in turn.
  4. Iterators And Generators (7 labs): You can explain what a for loop does in terms of iter and next, write a generator function with yield, and say why a generator costs no memory however long its sequence is.

Object Oriented Python

  1. Classes And Instances (6 labs): You can write a class with an initialiser, create instances of it, store data on each instance, and explain the difference between the class and an instance of it.
  2. Methods, Attributes And self (7 labs): You can write methods that use self, tell instance attributes from class attributes, avoid the shared mutable class attribute trap, document a method, and expose a computed value as a property.
  3. Inheritance And Composition (7 labs): You can write a subclass that overrides a method and calls super, test types with isinstance, build the same design out of composition instead, and choose between the two on purpose.
  4. Dunder Methods, And Making Objects Pythonic (8 labs): You can give a class a useful repr and str, define equality and hashing consistently, make an object work with len, indexing and a for loop, and reach for a dataclass when the class is plain data.

Files, Formats And The Standard Library

  1. Paths And Files The Modern Way (8 labs): You can open every file with a with statement, read it whole or line by line, append to it, choose an encoding on purpose, and build paths with pathlib that work on any operating system.
  2. JSON And CSV (5 labs): You can save and load Python data as JSON, say which Python types survive the trip, and read a comma separated file with the csv module instead of splitting the line yourself.
  3. Dates, Times And Random (8 labs): You can make and compare dates, do arithmetic with timedelta, format and parse them with strftime and strptime, and generate random numbers you can reproduce with a seed.
  4. A Standard Library Tour (6 labs): You can name the standard library modules a beginner actually meets, say what each one is for, recognise when a problem belongs to one of them, and look the details up for yourself.

Testing, Typing And Shipping

  1. Testing With pytest (6 labs): You can write a test file of plain assert statements, run it with pytest, read a failure report, and say which cases are worth a test of their own.
  2. Type Hints (5 labs): You can annotate a function's parameters and return value, write the common types including lists, dictionaries and optional values, explain that hints change nothing at runtime, and check them with mypy.
  3. Formatting, Linting And Style (6 labs): You can name and lay out code the way the rest of the Python world does, let a formatter settle the arguments, read what a linter reports, and write a docstring worth reading.
  4. Shipping: scripts, entry points and git (7 labs): You can turn a script into a command you can run from anywhere, describe your project in a pyproject file, build and install it, and keep its history in git.

Certification courses