Source: https://mokxi.com/learn/path/python-for-science
Updated: 2026-11-20

All paths

# Python for science and math

Space science in plain Python on a Raspberry Pi: units, numeric methods, Euler steps from a falling ball to an orbit, Monte Carlo, the statistics of a sensor, least squares, and a photogate pendulum that measures g.

Raspberry Pi 4 Model B Free 7 lessons 5 h 4 chapters 2,063 XP Coding · Intermediate +150 XP

0 of 7 done

Start the course free Units Lesson plan for teachers

What you will build

## 3 projects, built step by step

7 lessons in 4 chapters, about 5 hours on a simulated Raspberry Pi 4 Model B. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### Numeric methods

How computers actually solve math: Newton's method for square roots, a stopping rule, bisection for any equation, Kepler's equation for where Mars is in its orbit, and the trapezoid rule for areas, with the error measured each time.
Open it in the simulator

Chapter 2 project

### Monte Carlo

Answer hard questions with random numbers: estimate pi from darts, measure how the error shrinks with more samples, find a Mars lander's chance of hitting a boulder, and use seeds so a random experiment can be repeated exactly.
Open it in the simulator

Chapter 3 project

### Fitting a line

Find the law in the data: straighten a pendulum's curve by plotting T^2 against length, fit the best line by least squares written by hand, read g from its slope, judge the fit with residuals and R^2, and use it to predict.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## Numbers that mean something

Units that crashed a probe, floats that are not exact, and methods that solve equations by guessing well.

Open 236 XP

### Units

Numbers in science carry units: weigh an astronaut on Mars, redo the arithmetic that lost the Mars Climate Orbiter, time a radio signal across the solar system, write huge numbers in scientific notation, and meet the float that is not quite 0.3.

0 of 6 steps

Start What is in it

Project Locked 410 XP

### Numeric methods

How computers actually solve math: Newton's method for square roots, a stopping rule, bisection for any equation, Kepler's equation for where Mars is in its orbit, and the trapezoid rule for areas, with the error measured each time.

0 of 5 steps

5 questions, graded as you go.

Chapter 2

## Simulate it

Step time forward to drop a ball and fly an orbit, and throw random darts to answer what formulas cannot.

Locked 236 XP

### A falling ball

Simulate motion the way physics engines do, one small time step at a time: a ball dropped on Earth and on Mars, the cost of a big step, air drag that no formula solves neatly, and an orbit around Earth that drifts until one swapped pair of lines fixes it.

0 of 6 steps

Project Locked 348 XP

### Monte Carlo

Answer hard questions with random numbers: estimate pi from darts, measure how the error shrinks with more samples, find a Mars lander's chance of hitting a boulder, and use seeds so a random experiment can be repeated exactly.

0 of 4 steps

5 questions, graded as you go.

Chapter 3

## Measure it

Mean, spread and error bars, a sensor against a stopwatch, and the best line through the data.

Locked 205 XP

### Statistics of a sensor

Turn a pile of measurements into a result: mean, standard deviation by hand, the standard error that shrinks with more data, the statistics module as a check, and then a photogate on the Pi that measures the same swing far better than a thumb on a stopwatch.

0 of 5 steps

Project Locked 410 XP

### Fitting a line

Find the law in the data: straighten a pendulum's curve by plotting T^2 against length, fit the best line by least squares written by hand, read g from its slope, judge the fit with residuals and R^2, and use it to predict.

0 of 5 steps

4 questions, graded as you go.

Chapter 4

## Project

Build a photogate pendulum and measure gravity, on Earth and on Mars, with an honest error bar.

Locked 218 XP

### Project: measure g with a pendulum

The finale: time a pendulum with a photogate on GPIO17, turn the times into g, take the experiment to Mars, put an honest error bar on the result, and write a program that works out which world the pendulum is swinging on.

0 of 6 steps

4 questions, graded as you go.

Syllabus

## Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### Numbers that mean something

- Units Numbers in science carry units: weigh an astronaut on Mars, redo the arithmetic that lost the Mars Climate Orbiter, time a radio signal across the solar system, write huge numbers in scientific notation, and meet the float that is not quite 0.3.
- Numeric methods How computers actually solve math: Newton's method for square roots, a stopping rule, bisection for any equation, Kepler's equation for where Mars is in its orbit, and the trapezoid rule for areas, with the error measured each time.

Chapter 2

### Simulate it

- A falling ball Simulate motion the way physics engines do, one small time step at a time: a ball dropped on Earth and on Mars, the cost of a big step, air drag that no formula solves neatly, and an orbit around Earth that drifts until one swapped pair of lines fixes it.
- Monte Carlo Answer hard questions with random numbers: estimate pi from darts, measure how the error shrinks with more samples, find a Mars lander's chance of hitting a boulder, and use seeds so a random experiment can be repeated exactly.

Chapter 3

### Measure it

- Statistics of a sensor Turn a pile of measurements into a result: mean, standard deviation by hand, the standard error that shrinks with more data, the statistics module as a check, and then a photogate on the Pi that measures the same swing far better than a thumb on a stopwatch.
- Fitting a line Find the law in the data: straighten a pendulum's curve by plotting T^2 against length, fit the best line by least squares written by hand, read g from its slope, judge the fit with residuals and R^2, and use it to predict.

Chapter 4

### Project

- Project: measure g with a pendulum The finale: time a pendulum with a photogate on GPIO17, turn the times into g, take the experiment to Mars, put an honest error bar on the result, and write a program that works out which world the pendulum is swinging on.

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Python for science and math

Is Python for science and math free?

Yes. All 7 lessons of Python for science and math are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Raspberry Pi 4 Model B?

No. Every lesson runs on a simulated Raspberry Pi 4 Model B with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Python for science and math take?

About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Numeric methods, Monte Carlo and Fitting a line.

Where do I start?

With "Units", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
