Python code
Python cells run in Pyodide, a build of Python for the browser, inside IPython, the same shell a Jupyter kernel runs. Real Quarto renders a Python document with Jupyter: it runs the cells in a kernel, then turns the outputs into markdown. The playground does both steps the same way. It runs Quarto’s own kernel setup code first, and the outputs-to-markdown step is ported from Quarto’s source. For documents with only Python cells, the rendered HTML matches native Quarto.
Python runs in a background worker, so a slow cell never freezes the lesson. The first Python render downloads Pyodide and IPython (about 15 MB), plus the packages the document imports.
Output, tables and inline code
As in Jupyter, a cell shows the value of its last line, and display() shows anything earlier. pandas tables, IPython.display.Markdown and other rich output render as HTML.
The last cell fails on purpose. With error: true, its error appears in the document, as it would in Jupyter, instead of stopping the render. Without it, the render stops and the playground names the failed cell.
pandas often returns NumPy numbers, and NumPy 2 displays these as np.float64(86.3). That is what real Quarto shows too. Format numbers as text, for example with an f-string such as f"{x:.1f}", or convert them with float() or int().
Figures
matplotlib figures appear where plt.show() is called, or at the end of the cell. Quarto’s figure options apply: label, fig-cap, fig-subcap, layout-ncol and the rest. Figure size comes from fig-width and fig-height in the document’s YAML (7 × 5 inches by default), as Quarto’s kernel setup sets them.
matplotlib is about 13 MB, so this playground waits for ▶ Render:
Packages
Imports load packages automatically:
- Packages included in Pyodide download on first import. These include numpy, pandas, matplotlib, scipy, scikit-learn and many more.
- Pure-Python packages from PyPI, such as seaborn, are installed with
micropipif Pyodide doesn’t include them. - Anything else fails with
ModuleNotFoundError, as a missing package would.
Stopping long-running code
If a cell runs for more than a second or two, a ■ Stop button appears. Stopping ends the Python session, and the next render starts a fresh one. Try it:
Supported cell options
echo(includingecho: fenced),eval,include,output(includingoutput: asis),warninganderror, per cell or underexecute:label,fig-cap,fig-subcap,fig-alt,tbl-capand layout optionscode-fold,code-summary,code-line-numbersandcode-overflow- Inline code,
`{python} expr`
Differences from Jupyter
- Warnings show a short file name (
<ipython-input-3-…>) where Jupyter shows a temporary file path. - Figures may differ from native output by a pixel, because fonts differ.
- Not available: reading local files, network access from Python, interactive widgets (ipywidgets, plotly),
input(), and packages that are neither in Pyodide nor pure Python. - R and Python together. Quarto renders a document with both through knitr and reticulate. The playground runs both languages, but formats the Python output only approximately, and the languages can’t share variables (
py$x,r.x).