# Python Playground

Run Python in your browser with Pyodide, prepared standard input, console output and coding examples.

## URL

https://ilham.dev/tools/python-playground/

## What It Does

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.

## Features

- Pyodide browser runtime
- Prepared standard input
- Run and Stop
- Coding exercises and pyramid patterns

## Input

Python snippet with optional prepared standard input python input.

## Output

Print output, expression results and errors console output.

## Privacy

Processing happens locally in the browser.

No input data is uploaded to ilham.dev.

- Requires login: false
- Requires API key: false
- Stores user data: false


## Examples

- How does input() work?
- Why does the first Run take longer?
- Can I use pip or any Python package?
- Does choosing an example erase my code?
- Is this a security sandbox?


## Limitations

- Pyodide loads from jsDelivr on Run; extra packages are not installed automatically.
- Prepared input is not a live interactive terminal.
- A fresh Worker is created for each run; state is not preserved.
- Worker execution is not a security sandbox; code can use browser APIs through the JavaScript bridge.
- Execution is limited to 30 seconds and 500 output rows.


## Related Tools

- https://ilham.dev/tools/javascript-playground/
- https://ilham.dev/tools/typescript-playground/
- https://ilham.dev/tools/ruby-playground/
- https://ilham.dev/tools/c-playground/
- https://ilham.dev/tools/cpp-playground/


## 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.

