Emmanuel Akinfulubi

Playground

There is no Python in a browser, so the honest version of a playground for this course is the three commands that give you one on your own machine. The scratchpad underneath is JavaScript, which the page really can run.

The real playground is one command

Python ships an interactive interpreter. Typing python3 with no arguments gives you the >>> prompt, which evaluates as you type and is the fastest way to answer "what does this actually do":

The interactive interpreter, in your terminal

shown, not run
$ python3
Python 3.14.7 (main, Aug  5 2026, 10:29:49) [Clang 17.0.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1 + 0.2
0.30000000000000004
>>> len("hello")
5
>>> exit()

A transcript of an interactive session rather than a runnable panel: it is showing what your own terminal does, and there is no interpreter in this page to reproduce it. Everything it demonstrates is checked for real in the lessons.

For anything longer than a line or two, put it in a file and run that instead (python3 scratch.py). And when a project needs a package, give it its own environment first — lesson 21 covers exactly why, and what goes wrong when you skip it.

A JavaScript scratchpad, which does run here

Same runner the JavaScript panels in the lessons use, with the assertion helper already defined. It is here so there is something in the page itself to poke at.

Scratch

runs here
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
const test = (name, got, want) => console.log(
  (same(got, want) ? 'ok   ' : 'FAIL ') + name +
  (same(got, want) ? '' : `  got ${JSON.stringify(got)}, want ${JSON.stringify(want)}`)
);
// Never use === on a computed float. See the lesson on numbers.
const close = (a, b, tol = 1e-9) => Math.abs(a - b) < tol;

// Try something. test(name, got, want) prints ok or FAIL.
const counts = (words) => words.reduce((acc, w) => {
  acc[w] = (acc[w] || 0) + 1;
  return acc;
}, {});

console.log(counts(['a', 'b', 'a']));
test('counting words', counts(['a', 'b', 'a']), { a: 2, b: 1 });

Output


      

Newsletter

New writing, when it lands.

Occasional notes on shipping software with AI agents. No schedule, no filler, unsubscribe in one click.