Python

Real Python 3, running right in your browser. No install, and it works on Chromebooks.

Running your program

Press ▶ Run (or Ctrl + Enter). The first run takes a few seconds while Python loads; after that it's quick. Output appears on the right as your program prints it.

Stop ends the program at any time, even an endless while True: loop. Python runs in the background, so a stuck program never freezes the page.

Asking for input

When your program calls input(), a text box appears right in the output. Type your answer and press Enter:

name = input("What's your name? ")
print("Hi", name)

More than one file

Add a file with + (it must end in .py), then import it:

# helpers.py
def greet(name):
    return "Hello, " + name + "!"

# main.py
from helpers import greet
print(greet("Ada"))

Your program always starts from main.py.

Libraries

Everything built into Python works: random, math, datetime, collections and the rest. Many popular packages load by themselves the first time you import them, like numpy. The first time takes a few extra seconds.

Errors

Errors show in red, with the line they happened on:

Traceback:
  File "main.py", line 4, in <module>
    print(10 / 0)
ZeroDivisionError: division by zero

The last line says what went wrong. The line above it shows where.

Good to know

  • Programs can't open windows or draw with turtle. They print text. The ASCII Art Studio and Maze Maker show how far that goes.
  • Files your program writes last until it finishes running.
  • If a program prints a huge amount, output stops after about 20,000 writes so the page stays usable.
  • Published Python projects run for anyone who opens the link, with the same Run experience.