Python code

Press Ctrl/Cmd + Enter to run. Auto-run reruns 700 ms after editing. Enable Monaco for highlighting; it loads from a CDN only when requested.

Pyodide 0.28.2 downloads its Python runtime and core standard library from jsDelivr on your first Run. Loading may take a moment. Fill standard input before Run; this is not a live terminal. No additional packages are installed automatically.

Code examples (20)

Click an example to add it above your code. Existing code stays; Auto-run is paused. Clear the editor first if you want to run only the example.

Basics

Number exercises

Logic exercises

Arrays and search

Functions and OOP

Star patterns

Plain editor
0 lines · 0 chars

Output

Use input() to read the prepared standard input. Runs in a Web Worker, without direct DOM access. Stop terminates execution; each run has a 30-second execution limit 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.

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. Prepare standard input before execution and 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?
Fill Standard input before Run, with one answer per line. Each input() consumes the next line. Missing answers produce an EOFError. This is prepared input, not a live interactive terminal.
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 then has a separate 30-second limit. 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?
No. It adds the example above your code and pauses Auto-run. Clear the editor first to run only the example. The input example fills standard input only if that field is empty.
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.