# Runnable Python Profile

This optional profile applies only when the host project enables runnable
Python. It defines the complete fenced-code contract for that project.

### PY-01 — Use one runnable fence form

Every fenced code block in slide Markdown **MUST** use `py {monaco-run}` plus
one Monaco metadata object, for example:

````md
```py {monaco-run} {autorun:false,outputHeight:'3rem'}
print("hello")
```
````

Plain `py`, `python`, `text`, `sh`, and other fenced formats **MUST NOT** appear
in slides covered by this profile.

### PY-02 — Present non-executable material without a fence

If material is not executable Python, use inline code, a table, SVG, or a
purpose-built component instead of a fenced code block.

### PY-03 — Make every runner independent

Every program **MUST** execute from a fresh state, define every name it uses,
avoid hidden state from another slide, and produce meaningful visible output.

### PY-04 — Keep teaching programs minimal

A runner **MUST** contain only the code needed for its teaching burden. Do not
add boilerplate solely to make a decorative snippet executable; redesign the
example instead.

### PY-05 — Separate top-level definitions visually

Leave at least one blank line after a top-level `class` or `def` body before the
next top-level definition or executable statement.

### PY-06 — Measure actual output

Before adding or changing a runner, execute the unmodified program and count
all visible output lines, including intentional blanks. Set `outputHeight`
from that result.

### PY-07 — Keep Monaco properties in one object

Use one metadata object and a simple CSS length. Multiple property objects and
comma-containing `min()` values **MUST NOT** be used because the metadata parser
does not handle them reliably.

### PY-08 — Use the output-height reference scale

Use approximately `1.6rem` per output line plus `1.3rem` vertical padding,
rounded to a practical value:

| Visible lines | `outputHeight` |
|---:|---:|
| 1 | `3rem` |
| 3 | `6rem` |
| 6 | `11rem` |
| 10 | `18rem` |
| 13 | `23rem` |

For output expected to exceed about 18 lines, use `32rem` and rely on the host
project's verified global cap and internal scrolling. For data-dependent
programs, size for the normal teaching fixture and choose the next larger
reference value.

### PY-09 — Update height whenever output changes

If the program changes, rerun it and update `outputHeight` whenever the visible
line count changes.
