Python
print("Welcome to Online IDE!")
print("Start coding in Python...")

def sum(a, b):
    return a + b

a = int(input("Enter a number: "))
b = int(input("Enter another number: "))
print(f"The sum of {a} and {b} is {sum(a, b)}")

Press Run or Ctrl ↵ to execute main.py.
Type program input here while it runs.

Python

Online Python Compiler

Your code runs on CPython 3.12, the interpreter from python.org, and run settings switch it to 3.11, 3.13, 3.14 or 3.15. When the program calls input(), it pauses until you type an answer in the console and press Enter, as it would in a terminal.

Try it above

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

A program that reads input

This reads a class size, then a name and a score per line, and prints the average and a grade table. Each prompt waits for you in the console:

Python
n = int(input("How many students? "))
scores = {}
for i in range(n):
    name, score = input(f"Name and score #{i + 1}: ").split()
    scores[name] = int(score)

average = sum(scores.values()) / n
best = max(scores, key=scores.get)
print(f"Average: {average:.1f}")
print(f"Best: {best} ({scores[best]})")
for name, score in sorted(scores.items(), key=lambda kv: kv[1], reverse=True):
    grade = "A" if score >= 90 else "B" if score >= 80 else "C" if score >= 70 else "F"
    print(f"{name:<6}{score:>4}  {grade}")
Terminal
$ python3 -u main.py
How many students? 3
Name and score #1: Ada 91
Name and score #2: Linus 78
Name and score #3: Grace 85
Average: 84.7
Best: Ada (91)
Ada     91  A
Grace   85  B
Linus   78  C

input() always returns a string, so the score goes through int(). split() with no argument splits on any run of spaces, which is how “Ada 91” unpacks into a name and a score.

How input reaches your program

The console hands the program one line each time you press Enter. Pasting several lines sends them one after another, so a whole test case can go in at once.

  • One value per line: n = int(input()). int() ignores the spaces and the newline around the number.
  • Several values on one line: a, b = map(int, input().split()), or nums = list(map(int, input().split())) for a list.
  • Many thousands of lines, as on judge problems: import sys and read with sys.stdin.readline(), which is faster than input() in a loop.
  • There’s no end-of-input key. The console can’t send Ctrl+D, so sys.stdin.read() and for line in sys.stdin: keep waiting until the input wait in the table above runs out. Read a count first, or stop at an empty line with while line := input():.
  • Ctrl+C in the console stops the run.

Several files and the entry file

Add a file with the + after the tabs, say helpers.py, and import it from main.py:

Python
# helpers.py
def slugify(text):
    return "-".join(text.lower().split())

# main.py
from helpers import slugify

print(slugify("Hello Python World"))
Terminal
$ python3 -u main.py
hello-python-world
  • Run starts the open tab unless run settings name an Entry file. Press Run while helpers.py is showing and Python runs that file, which defines a function and prints nothing.
  • Playground files sit side by side with no folders, so a package with subfolders needs a project (see the Python IDE page).
  • Uploaded files land in the program’s working folder, so open("scores.csv") finds them. A CSV your program writes opens as a new tab after the run; an .xlsx from openpyxl, being binary, doesn’t come back to the playground, but a project keeps it.

What isn’t available

  • pip install. Code Runner has the standard library plus NumPy, pandas and openpyxl, with the packages they depend on. import requests stops with ModuleNotFoundError: No module named 'requests', and the console adds a tip to switch Python to “This browser”, where imports install themselves.
  • Network calls. urllib.request.urlopen() and socket connections fail because runs are offline; save a response as a file and upload it to test parsing code.
  • A >>> prompt. Run executes the whole file each time; the Python interpreter page covers what that means and the alternatives.

Errors you’re likely to see

  • “ValueError: invalid literal for int() with base 10: '3 4'”: two numbers were typed where the code reads one with int(input()). Read them with input().split().
  • “TypeError: can only concatenate str (not "int") to str”: "Age: " + age with a number. Use an f-string, f"Age: {age}", or str(age).
  • “IndentationError: expected an indented block after 'if' statement on line 2”: the line under an if, for, def or while needs indenting. Select it and press Tab.
  • “NameError: name 'math' is not defined. Did you forget to import 'math'?”: add import math at the top. The “Did you forget” hint is new in 3.12; 3.11 prints only the first sentence.
  • “UnboundLocalError: cannot access local variable 'total' where it is not associated with a value”: a function assigns to a variable defined outside it. Pass the value in and return the new one, or declare global total.
  • “IndexError: list index out of range”: the index is len(xs) or more. The last item is xs[-1].

Tracebacks print in red, and a line such as File "/workspace/main.py", line 7 is a link to that line in the editor. After a failed run, Fix with AI reads the traceback and proposes a change you review before it applies.

Versions, recursion and speed

  • 3.12 lets f-strings reuse their own quotes: f"{row["name"]}" works, while 3.11 stops with SyntaxError: f-string: unmatched '['. If a course or judge runs 3.11, select it so this kind of code fails here first.
  • Deep recursion ends with RecursionError: maximum recursion depth exceeded at about 1,000 nested calls. Raise the limit with sys.setrecursionlimit(), or turn the recursion into a loop with your own stack.
  • Loops over millions of numbers in pure Python are slow; NumPy does the same arithmetic on whole arrays in compiled code (see NumPy online and pandas online).
  • The exit code and run time show under the console after each run; hover them for the CPU time used.

Questions

Is this a Python compiler or an interpreter?

Both words fit. CPython compiles your file to bytecode and then interprets it, all inside the one python3 command that Run starts. No separate build step happens and no .exe comes out.

Which Python version does it use?

Python 3.12, unless you pick 3.11, 3.13, 3.14 or 3.15 in run settings. The choice is remembered in this browser.

How do I enter more than one input?

Type each answer and press Enter, or paste several lines at once: each line feeds one input() call. For several values on one line, split it with input().split().

Can I install packages with pip?

Not on Code Runner. Switch Run Python on to “This browser” in run settings: there, Pyodide installs a package the first time you import it, if it’s built for Pyodide or is a pure-Python wheel.

Is there a debugger?

Yes. Click left of a line number to set a breakpoint and press Debug next to Run. The code runs in your browser and stops there, showing its variables and call stack.

Why does my program never finish reading input?

It’s waiting for the end of input, which the console can’t send. Loops over sys.stdin and sys.stdin.read() need a count or a stop line instead.