Skip to content

Bonus · A self-checking maths task

This page isn't about music — it shows why you'd build a maths carrier on a Python toolchain. The task below checks a learner's algebra with real sympy, running entirely in the browser via Pyodide (WebAssembly). No server, no round-trip — the same sympy you'd use to author and verify the maths also marks the student's answer.

Expand the brackets

Expand \((x+1)^2\). Type your answer as a Python-style expression, e.g. x**2 + 2*x + 1.


Loading…

Another one

Write an expression equivalent to \((x+3)(x-3)\).


Loading…

What just happened

The check isn't a string match. Behind the scenes sympy evaluates:

from sympy import *
x, y, z = symbols('x y z')
simplify(sympify(user_answer) - expand((x + 1)**2)) == 0

So any equivalent form is acceptedx**2 + 2*x + 1, 1 + 2*x + x**2, or even (x+1)**2 — not just the one you typed. That's the difference between a quiz widget and actual mathematics: the marking understands the maths.

Why this matters for the studio

The mathroom house rule is to sympy-verify any on-screen maths. With Pyodide that exact verification can run in the lesson itself, so the answer key and the student's marking come from the same source of truth.