How to use the online Python compiler
- Write or paste your code into the editor. The page starts with a short example; Reset example brings it back at any time.
- If your program calls
input(), type the answers into the Input (stdin) box below the output, one line perinput()call. - Press Run or use Ctrl + Enter (⌘ + Enter on a Mac).
- Read the result in the Output panel. Anything printed to
stderr, including tracebacks, is highlighted as an error. - Choose a time limit of 5, 15 or 60 seconds. If a script runs longer (an accidental
while True:, for example), it is stopped automatically. You can also press Stop at any moment.
The first run downloads the Python runtime, about 10 MB. Your browser caches it, so later runs start much faster. Use Copy or main.py to save your script.
Your code never leaves your device. Python runs inside your browser in a Web Worker, so nothing is uploaded to or stored on our servers. The editor remembers your last code in your browser's local storage, and in no other place.
What's supported
The compiler uses Python 3.12 through Pyodide 0.26, the CPython interpreter compiled to WebAssembly. It is real CPython, not a Python-like imitation, so the language behaves exactly as it does on your computer.
- The standard library:
math,collections,itertools,datetime,json,re,dataclasses,statisticsand more. - Automatic package loading: when your code imports a package that Pyodide provides, such as NumPy or pandas, it is downloaded on the fly. Many pure-Python and scientific packages are available.
- Standard input through
input()andsys.stdin, fed from the stdin box. async/await: code runs withrunPythonAsync, so a top-levelawaitworks.
Limitations to keep in mind:
- No network sockets. Modules such as
socket,urllib.requestandrequestscannot open connections from here. - No persistent files. You can create and read files with
open(), but they live in memory and are lost when you reload the page or press Stop. - Plots are not displayed. matplotlib can be imported, but no figure is shown, so print numbers or tables instead.
- Packages with native code that Pyodide does not ship cannot be installed.
Python quick reference
from dataclasses import dataclass
@dataclass
class Item:
name: str
price: float
cart = [Item("pen", 1.5), Item("book", 12.0)]
total = sum(i.price for i in cart)
print(f"{len(cart)} items, total {total:.2f}")
if total > 10 and cart:
print("Free shipping!")
| Task | Syntax |
|---|---|
| Print formatted text | print(f"{x:.2f}") |
| Read a line of input | name = input("Name? ") |
| Convert input to a number | n = int(input()) |
| List comprehension | [x * 2 for x in data if x > 0] |
| Dictionary loop | for k, v in d.items(): |
| Handle an error | try: ... except ValueError as e: ... |
Tips
- If your program asks for input more often than the stdin box has lines, Python raises
EOFError. Add a line for everyinput()call. - Large imports like pandas take a few seconds the first time. The download counts toward the time limit, so pick 60 s for heavy scripts.
- Each run starts with fresh variables, but modules you have already imported stay loaded, so repeat runs are quick.
- Working with JSON output? Paste it into the JSON formatter to pretty-print and validate it.
Frequently asked questions
Is this a real Python interpreter?
Yes. Pyodide is CPython 3.12 compiled to WebAssembly. The syntax, built-in functions and standard library match desktop Python. The main differences come from running in a browser: there is no network access and no permanent file system.
Can I use NumPy and pandas?
Yes. Import them as usual and they are downloaded the first time you run the code. Many other scientific and pure-Python packages that Pyodide provides load in the same way.
How do I give my program input?
Type the values into the stdin box, one line for each input() call, in the order your program asks for them. Then press Run.
Why does my script stop after 15 seconds?
The default time limit protects you from infinite loops that would freeze the tab. Choose 60 s from the time limit menu for longer computations.
Can I run other languages too?
Yes. Try the online JavaScript compiler or browse all the free developer tools.