Python Playground

Python code

Options

Choosing an example replaces code and input, and pauses Auto-run. Multiline code requires confirmation.

The first Run downloads the language runtime from jsDelivr. Ctrl/Cmd + Enter runs code. Monaco loads from a CDN only when enabled.

Plain editor

Interactive input waits for each answer in the console. Requires HTTPS and service workers; no backend and no persisted input.

0 lines · 0 chars

Monaco offers word suggestions (Ctrl + Space), plus JavaScript/TypeScript syntax and type diagnostics. Other languages have limited suggestions; check errors after Run. Suggestions need Monaco.

Console

You can type ahead. Enter sends a line when the program asks; EOF ends input. Answers are echoed in the console, not saved.

Timing measures elapsed time, not CPU time; waiting for input is included. WASM memory, when available, is linear memory capacity, not total RAM or peak usage.

Use input() for terminal input. Runs in a Web Worker, without direct DOM access. Stop terminates execution; execution outside input waits is limited to 30 seconds, each answer can wait up to 2 minutes, and output is capped at 500 rows. Code can still make network requests, so only run code you trust. The tool does not save or upload your code or input.

Replace existing code?

Loading will replace the current code and input. Cancel to keep your work.

Runtime details

Interactive stdin installs a service worker scoped to /tools/ on its first Run. It answers only reserved input requests locally, without caching pages or persisting answers. If unavailable, use Prepared standard input. This is line-based input, not a shell or full terminal emulator.

Pyodide 0.28.2 downloads its Python runtime and core standard library from jsDelivr on your first Run. Loading may take a moment. Use interactive terminal input, or prepare standard input before Run. No additional packages are installed automatically.

Learn

Python Playground Guide

About this tool

Run Python in a disposable browser Worker using Pyodide 0.28.2. The runtime and core standard library load from jsDelivr only on Run or when Auto-run is enabled. Answer interactive input in the console or prepare input before Run. Read print output, expression results and errors in the console. Examples include prime numbers, odd/even lists, sorting, classes and pyramid patterns. No extra packages are installed automatically. The tool does not save or upload code or input; Python’s JavaScript bridge can still make network requests.

Questions

How does input() work?
In Interactive terminal mode, input() waits for a line in the console. Type an answer and press Enter. EOF (or Ctrl + D) ends input and can raise EOFError. Prepared standard input still accepts one answer per line before Run.
Why does the first Run take longer?
It downloads and initializes Pyodide and its core standard library. Runtime loading has a 90-second timeout. Execution outside input waits has a 30-second limit; each answer may wait up to 2 minutes. Each Run starts a fresh Worker; asset requests can use normal HTTP caching.
Can I use pip or any Python package?
No packages are installed automatically by this tool. Pure Python packages and specially built Pyodide packages may be possible through additional runtime APIs, but arbitrary native desktop packages do not work unchanged.
Does choosing an example erase my code?
Yes. Selecting immediately replaces code and standard input, and pauses Auto-run. If the editor contains more than one line, a confirmation warns that existing code will be deleted. Cancel to keep code and input.
Is this a security sandbox?
No. Python runs in a Worker without direct DOM access, but the JavaScript bridge can use browser APIs and make network requests. Only run code you trust. Stop terminates the Worker; code and input are not saved by the tool.