Runnable Python — demo & how-to
This page is infrastructure proof-of-life, not a lesson. It shows the "try it" box that authors can drop into the M1–M3 notes so learners run Python right in the page — no install, no account, no API key.
▶ These boxes run real Python in your browser
The first time you press Run on a page, the Python engine downloads — give it a few seconds to wake up (longer on a slow connection or an older laptop). After that it is quick, and it is cached. It did not break; it is just waking up.
Proof of life — press ▶ Run, then change a number and run again
Each box is independent and editable — edit the code above, or the one below, and run again.
How to add a "try it" box (instructor)
Drop this raw HTML wherever you want a runnable box in a notes page — that is the whole pattern:
<script type="py-editor">
print("edit me, then press Run")
</script>
- Put the one-time wait note (the
!!! tipadmonition shown above) near the top of any page that has a box. - Keep boxes to M1–M3 fundamentals: variables, types, logic, lists, dicts, functions, f-strings.
- Never put an API key, or AI/network code, in a box — the page is public and that code will not run in-browser.
Faithful vs. fast (a one-word swap)
py-editor→ Pyodide / CPython 3.13 (default): exactly matches real Python and the/lite/lab notebooks. First Run downloads a larger runtime (~10–30 MB).mpy-editor→ MicroPython (~1–2 MB): much faster first Run and fine for fundamentals, but a few stdlib/edge behaviours differ from CPython. Consider it if your learners are on weak connections.