Course

Python from the ground up

Your first programming language

  • Beginner
  • 15 chapters
  • 221 min read

A first course in programming with Python, from your very first line to classes, JSON and tests: every idea comes with a small program you can run in the page, explained in plain words, and a short quiz at the end of each chapter.

What You'll Learn

  • Run a Python program and read its output
  • Store values in variables and build sentences from them
  • Make a program choose with if, elif and else
  • Repeat work with loops, and package it in functions
  • Keep values in lists and dictionaries
  • Read and write files, and handle the errors that happen
  • Write a class with its own data and behaviour
  • Reach into the standard library with import
  • Sort data and build new lists with comprehensions
  • Save and load data as JSON
  • Work with dates, and count the days between them
  • Prove your functions with tests

Prerequisites

  • No prior programming experience — the course starts at zero
  • Any modern browser; the Python runtime runs in the page

Vocabulary

The terms the chapters assume, in plain words.

argument
A value you put inside the parentheses when you call a function, which the function then receives.
block
A group of lines that belong together under one opening line, such as the body of an if or a loop.
branch
A path a program can take when a condition sends it one way or another.
call site
The place in the code where a function is called, as opposed to where it is defined.
class
A template that bundles data with the code that works on it; each copy has its own values.
dictionary
A collection of key and value pairs, where a key is used to look up its value.
exception
An error that stops the normal flow of a program unless some code catches it.
function
A named piece of code that does one job and can be called whenever you need it.
function object
A function treated as a value, so it can be stored in a variable, passed to another function, or returned.
indentation
The spaces at the start of a line that show which block it belongs to.
integer
A whole number with no decimal point, such as 3, 0 or -12.
list
An ordered collection of values that you can grow, shrink and reach into by position.
parameter
A name in a function definition that stands for the value the caller will supply.
return value
The result a function hands back to the code that called it.
scope
The part of a program where a name can be used; a name made inside a function is not visible outside it.
traceback
The report Python prints when a program fails, listing the calls that led to the error.
variable
A name that refers to a value, so you can use that value again later or change it.

Course Content

  1. 01
    How Python runs

    What happens when you press Run: Python reads your file from the top, one line at a time, and the output is what your program says.

    Beginner · 12 min read

    Not started
  2. 02
    Variables and text

    Names for values: store a piece of text, change it once, and drop it into a sentence with an f-string.

    Beginner · 13 min read

    Not started
  3. 03
    Making decisions

    if, elif and else: the program asks a question and follows the first answer that is true.

    Beginner · 14 min read

    Not started
  4. 04
    Loops and repetition

    The same line, written once and run many times: for, range and while, and how to keep a loop from running forever.

    Beginner · 14 min read

    Not started
  5. 05
    Functions

    A name for a piece of work: give it inputs, get an answer back, and stop writing the same lines twice.

    Beginner · 14 min read

    Not started
  6. 06
    Lists and dictionaries

    Keeping many values under one name: a list when order matters, a dictionary when you look things up by name.

    Intermediate · 15 min read

    Not started
  7. 07
    Reading and writing files

    Notes that outlive the program: open a file, write to it, read it back — and close it the tidy way with with.

    Intermediate · 15 min read

    Not started
  8. 08
    When things go wrong

    How to read a traceback without panic, the three errors you will meet first, and catching the ones you can answer.

    Intermediate · 15 min read

    Not started
  9. 09
    Classes and objects

    A blueprint and the things made from it: your own type with its own data, and the methods that work on it.

    Advanced · 16 min read

    Not started
  10. 10
    Modules and the standard library

    Other people’s code, one line away: importing from the standard library that ships with Python — math, random and friends.

    Advanced · 15 min read

    Not started
  11. 11
    A small program, end to end

    Everything at once: a tiny to-do list that uses a function, a loop, a list and a file — and what to build next.

    Advanced · 18 min read

    Not started
  12. 12
    Sorting and comprehensions

    Putting a list in order, and building a new one from an old one — the two lines that replace a lot of loops.

    Intermediate · 15 min read

    Not started
  13. 13
    Working with JSON

    The data format of the web, and the one module that turns Python values into it and back again.

    Intermediate · 15 min read

    Not started
  14. 14
    Dates and times

    A value for a day: today, thirty days from now, and the two ways to write a date — for people and for machines.

    Intermediate · 14 min read

    Not started
  15. 15
    Testing your code

    Writing down what should be true, so a change that breaks it says so — the habit that separates working code from code that worked once.

    Advanced · 16 min read

    Not started