I’ve published a rudimentary proof of concept using PyScript (Pyodide underneath) in a GitHub repo and recorded a demo:
Current blocker for the project is handling of multiline input like while loops and functions definitions.
I’ve modified copybutton script to make the buttons send to code to the console. One can experiment with the console using either document.querySelector("#console").process() or document.querySelector("#console").terminal (Xterm.js terminal object) in the developer console.
Docs and similar terminal projects: