Programming

Python Variable Trace Table Generator

Generate a trace table for any Python program automatically: one row for every line that runs, a column for every variable showing its value after the line, and the output it printed — the same table you would draw by hand for a dry run, but always correct.
Real Python 3.11 in your browserNothing is uploaded

Code

Input for input() — one line per call

Runs real Python 3.11 (Pyodide) in your browser. Ctrl+Enter runs; after running, use ← and → to step.

Step through

Press Run to execute the code. The first run downloads the Python runtime (about 10 MB, once per visit).

Programs that run longer are stopped, so an infinite loop cannot freeze the page.

How to use this tool

  1. 1Paste a Python program or pick an example such as a loop.
  2. 2Press Run: the program runs with real Python and every line is traced.
  3. 3Read the table; turn on “Only show changed values” for the classic hand-written style.
  4. 4Download it as CSV or copy it as a Markdown table.

Frequently asked questions

Each row is a line that ran, in order. The variable columns show values after that line finished, which is how trace tables are drawn for exams and dry runs.

Yes. "Only show changed values" leaves a cell blank unless the variable changed on that line.

In "All lines" mode, local variables of a function appear as function.variable columns; choose "Main program only" to trace just the top-level code.

No. The tool runs real Python 3.11 (Pyodide, Python compiled to WebAssembly) inside your browser. The first run downloads the runtime (about 10 MB) once per visit; your code never leaves your device.