Python
Online Python Interpreter
Press Run and CPython executes your file as python3 -u main.py: the whole script, top to bottom, with input() reading the console as it goes. Run settings can switch to Pyodide instead, CPython 3.12 compiled to WebAssembly and running inside this tab.
Try it aboveHow Python runs here
- Versions
- Python 3.11, 3.12 (default), 3.13, 3.14, 3.15
- Run
python3 -u main.py- Limits per run
- 256 MB memory, 15 s of CPU time on 2 cores, 2 MB of output
- Time
- Up to 10 minutes a run (30 on a paid plan); waits 2 minutes for input (5 on a paid plan)
- Sandbox
- Each run gets its own Linux sandbox with no network access. Text files your program writes next to your code open as new tabs.
- Good to know
- NumPy, pandas, Matplotlib and openpyxl installed.
What the -u flag changes
The -u flag turns off output buffering. Without it, Python collects output that goes to a pipe and writes it in blocks; with it, each print() reaches the console straight away. So a prompt printed with end="" shows before input() waits, and a progress line that starts with \r rewrites itself in place:
import time for done in range(0, 101, 25): print(f"\rConverting... {done}%", end="") time.sleep(0.5) print("\nFinished")
Arguments, input and exit codes
Program arguments in run settings land in sys.argv. This script takes --top and counts the words in text you type or paste, stopping at an empty line because the console can’t send end of input:
import argparse from collections import Counter parser = argparse.ArgumentParser() parser.add_argument("--top", type=int, default=3) args = parser.parse_args() print("Type or paste text, then an empty line:") words = Counter() while line := input(): words.update(line.lower().split()) for word, count in words.most_common(args.top): print(f"{count:>3} {word}")
$ python3 -u main.py --top 2 Type or paste text, then an empty line: the cat sat on the mat The dog sat too 3 the 2 sat
- Arguments are split at spaces, and quotes don’t group words: --name "Ada Lovelace" arrives as three items. Up to 500 characters are passed.
- After each run the console prints the exit code, as in ** Process exited - Return Code: 0 **. An uncaught exception gives 1, an argparse usage error gives 2 (try --tp 2 with the script above), and sys.exit(3) gives 3.
Scripts, not a >>> prompt
Each Run starts a fresh interpreter, executes the file from the top and exits, so nothing carries over to the next run. To see a value partway through, print() it, or set a breakpoint and press Debug to read every local variable at that line.
Python’s interactive >>> shell isn’t in the playground; in a project on Premium, the Linux terminal starts it when you type python3.
Code Runner or This browser
Run settings → Run Python on picks where Run executes; Debug always uses the browser.
- Code Runner: CPython 3.11 to 3.15 on our servers, the same python3 you’d run on Linux, with program arguments, NumPy, pandas and openpyxl, and no pip.
- This browser: Pyodide 0.27, which is CPython 3.12.7 compiled to WebAssembly. It takes input() from the console and installs a package the first time you import it, from Pyodide’s own builds or as a pure-Python wheel from PyPI; an Install packages box in run settings does the same ahead of time. Program arguments and the version picker don’t apply.
- Pyodide can’t start threads or subprocesses, and plain socket connections don’t work in a browser; the Limits link in run settings opens Pyodide’s full list.
Questions
Is there an interactive Python shell?
There’s no >>> prompt in the playground: each Run executes the whole file. Print the values you want to see, or pause at a breakpoint with Debug and read them under Variables.
What does python3 -u mean?
Unbuffered output: everything the script prints goes to the console immediately instead of in blocks, so prompts and progress lines appear on time.
How do I pass command-line arguments?
Type them under Program arguments in run settings. They arrive in sys.argv[1:], split at spaces, when Python runs on Code Runner.
Which Python does the browser engine run?
Pyodide 0.27, built from CPython 3.12.7. It runs inside this tab, so loops that need many seconds keep that tab busy rather than a server.
Why did my script exit with code 2?
argparse exits with 2 when the arguments don’t match what it expects, after printing a usage line. Check Program arguments in run settings.