Free · 9 lessons · Python 3

Learn Python with math animations

Every lesson builds one pattern of the channel in a short script, line by line: first arrays and loops, then randomness and recursion, then simulations and grids. Each one ends with exercises, a quiz and flashcards.

What you need

Python 3 and two libraries: pip install numpy matplotlib. Run each script with python name.py.

Beginner

  1. Lesson 1 Arrays and angles with the golden angle numpy arrays with np.arange · arithmetic on a whole array at once · radians, np.cos and np.sin · from an angle and a distance to x and y · a scatter plot coloured by a value
  2. Lesson 2 Loops and remainders with the times table on a circle a for loop over pairs with zip · the remainder % and angles that wrap around · a line from two points with plt.plot · exploring by changing one parameter
  3. Lesson 3 Randomness and counting with the galton board random numbers with np.random.default_rng · True and False counted as 1 and 0 · counting with np.bincount · a list comprehension · a simulation checked against a formula

Intermediate

  1. Lesson 4 Loops that remember with the chaos game a loop that carries its state from step to step · random whole numbers with rng.integers · a while loop for a condition · arrays of points and slicing · np.column_stack
  2. Lesson 5 Formulas on arrays with the pendulum wave a physics formula applied to a whole array · np.round and print for a quick check · several plots side by side with plt.subplots · f-strings · phase: where in its swing a pendulum is
  3. Lesson 6 Functions and recursion with the sorting race functions, and passing a function as a value · recursion: a function that calls itself on smaller parts · a counter kept in a dictionary · assert to check a result · how work grows: n² against n·log n
  4. Lesson 7 Stepping through time with the ball in a spinning ring a simulation: small time steps in a while loop · vectors as numpy arrays · the dot product and a reflection · angles with np.arctan2, wrapped round · break to leave a loop

Advanced

  1. Lesson 8 Forces and integration with the three-body orbits Newton’s gravity as vectors · nested loops over pairs of bodies · the leapfrog method of integration · a 3-D array: step × body × coordinate · checking a simulation by what must not change
  2. Lesson 9 Grids and diffusion with the turing patterns 2-D arrays as a grid of cells · np.roll for neighbours, with edges that wrap around · the Laplacian: a cell against its neighbours · updating a whole grid in one line · showing an array with plt.imshow