PythonMastery

Run Python 3.14, 3.13, 3.12 or 3.11 in your browser

The online editor runs real CPython, compiled to WebAssembly, in four versions. Python 3.13 is the default. Choose another from the status line above the output.

Which parts of the site use which version

WherePython
The editor (playground)Any of the four. 3.13 until you choose another, and your choice is remembered.
The lessons, Tutorial Lab, programs, short answers, tips and error pages3.13
The notebook3.13
Code boxes embedded on other sites3.13

Everything outside the editor stays on 3.13 because every output printed on those pages was checked by running it on 3.13. On another version some of them would print something else, as the examples below show.

How to switch

  1. Open the editor and wait until the status line says Python 3.13.2 Ready. On a computer it sits above the output. On a phone, it is on the Output Console bar.
  2. Click it (or press Enter on it) and choose a version.
  3. Python restarts in that version. The first time you pick a version it downloads, about 11 MB. After that, your browser keeps it. Packages you installed need installing again.

The editor remembers your choice for your next visit. A share link made on 3.14, 3.12 or 3.11 opens on that version for whoever you send it to, without changing their own choice.

What changed between the versions

Each example below was run in the editor on all four versions. The table shows what it printed, and the links open it on the version you pick.

Quotes inside f-strings 3.12

Before 3.12, the quotes inside the braces of an f-string could not be the same kind as the quotes around it. Code written on a newer Python often does this, and it is a syntax error on 3.11.

python
scores = {"ana": 91, "ben": 78}
print(f"Ana scored {scores["ana"]}")
PythonWhat it prints
3.11
SyntaxError: f-string: unmatched '['
3.12, 3.13, 3.14
Ana scored 91

Open it in the editor on Python 3.11 3.12 3.13 3.14

The type statement 3.12

A short way to name a type, so a long type hint is written once.

python
type Point = tuple[float, float]

def distance(a: Point, b: Point) -> float:
    return ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5

print(distance((0, 0), (3, 4)))
PythonWhat it prints
3.11
SyntaxError: invalid syntax
3.12, 3.13, 3.14
5.0

Open it in the editor on Python 3.11 3.12 3.13 3.14

Error messages that suggest the fix 3.13

Each new version guesses what you meant in more places. 3.13 added a guess for a misspelled keyword argument, so the same mistake takes less hunting.

python
numbers = [3, 1, 2]
print(sorted(numbers, reversed=True))
PythonWhat it prints
3.11, 3.12
TypeError: 'reversed' is an invalid keyword argument for sort()
3.13, 3.14
TypeError: sort() got an unexpected keyword argument 'reversed'. Did you mean 'reverse'?

Open it in the editor on Python 3.11 3.12 3.13 3.14

copy.replace() 3.13

Make a changed copy of a dataclass (or a date, or a named tuple) in one call.

python
import copy
from dataclasses import dataclass

@dataclass
class Point:
    x: int
    y: int

p = Point(1, 2)
print(copy.replace(p, x=10))
PythonWhat it prints
3.11, 3.12
AttributeError: module 'copy' has no attribute 'replace'
3.13, 3.14
Point(x=10, y=2)

Open it in the editor on Python 3.11 3.12 3.13 3.14

Template strings (t-strings) 3.14

They look like f-strings, but give you the text and the values separately instead of joining them, so a library can check or escape the values first.

python
name = "Ana"
greeting = t"Hello {name}!"
print(type(greeting).__name__)
print(greeting.strings, greeting.values)
PythonWhat it prints
3.11, 3.12, 3.13
SyntaxError: invalid syntax
3.14
Template
('Hello ', '!') ('Ana',)

Open it in the editor on Python 3.11 3.12 3.13 3.14

except without brackets 3.14

Catching two exception types no longer needs brackets around them.

python
try:
    int("abc")
except ValueError, TypeError:
    print("not a number")
PythonWhat it prints
3.11, 3.12, 3.13
SyntaxError: multiple exception types must be parenthesized
3.14
not a number

Open it in the editor on Python 3.11 3.12 3.13 3.14

asyncio.run() on 3.11 this editor

Python 3.11 here runs on an older Pyodide that cannot pause a program while it waits, so asyncio.run() does not work on 3.11 in this editor. It works on 3.12 and newer. On every version, you can write await at the top level instead.

python
import asyncio

async def main():
    await asyncio.sleep(0.1)
    return "done"

print(asyncio.run(main()))
PythonWhat it prints
3.11
RuntimeError: asyncio.run() does not work on Python 3.11 in this editor. (...)
3.12, 3.13, 3.14
done

Open it in the editor on Python 3.11 3.12 3.13 3.14

Same pandas code, three answers pandas 1.5, 2.x and 3.0

The pandas version changes with the Python version here. Averaging a group that has a text column drops that column with a warning on 3.11 (pandas 1.5), and raises an error on the newer ones, with new wording on 3.14 (pandas 3.0).

python
import pandas as pd
df = pd.DataFrame({"team": ["a", "a", "b"], "name": ["x", "y", "z"], "score": [1, 2, 3]})
print(df.groupby("team").mean())
PythonWhat it prints
3.11
FutureWarning: The default value of numeric_only in DataFrameGroupBy.mean is deprecated. (...)
      score
team       
a       1.5
b       3.0
3.12, 3.13
TypeError: agg function failed [how->mean,dtype->object]
3.14
TypeError: dtype 'str' does not support operation 'mean'

Open it in the editor on Python 3.11 3.12 3.13 3.14

Packages on each version

Each version comes with its own copy of the scientific packages, built for the browser:

Package3.143.13 (default)3.123.11
Exact version3.14.23.13.23.12.73.11.3
NumPy2.4.62.2.52.0.21.26.4
pandas3.0.22.3.02.2.31.5.3
scikit-learn1.8.01.7.01.6.11.3.1
Matplotlib3.10.83.8.43.8.43.5.2
SciPy1.18.01.14.11.14.11.11.2
pydantic2.12.52.10.62.10.51.10.7
Compiled packages built in357340351260
  • 3.14 has pandas 3.0, which changed some pandas behaviour: text columns get their own str type, and some errors are worded differently.
  • 3.11 has older NumPy (1.26) and pandas (1.5) than a desktop install of 3.11 would get today, and pydantic 1 instead of 2. The browser build for 3.11 stopped being updated in early 2024.
  • Packages written in pure Python (seaborn, Django and most of PyPI) install the newest release that supports your version, as pip would on a computer.
  • When a package cannot install on your version but can on another, the editor says which, in the output.

What is different from Python on your computer

The same on every version, because the code runs inside a browser tab:

On a computerIn the browser
subprocess, multiprocessing, threadsNot available. A browser tab cannot start programs or threads.
tkinter, turtleNot available: there are no desktop windows.
Any package from PyPIPure-Python packages, plus the compiled ones built for the browser. No PyTorch or TensorFlow.
requests.get() to any websiteOnly to sites that allow requests from browsers (CORS), such as many public APIs. The editor explains the error when a site does not.
urllib with https://Not available. Use requests.
Files on your diskFiles live in the browser’s storage. Upload them to the editor, and download what your code writes.
As much memory as the computer hasA few gigabytes at most. Very large data can stop the tab.

Packages installed from PyPI are not tested in the browser by anyone, so now and then one installs but fails when it reaches something from the table above.

Why these four

Python runs in the browser thanks to Pyodide, which builds CPython and its scientific packages for WebAssembly. Each Pyodide release carries one Python version, and the editor offers the newest release for each of 3.11, 3.12, 3.13 and 3.14. Python 3.10 is not offered: its browser build is from January 2023 and many current packages no longer install on it. Python 3.15 will be added when Pyodide’s first full release for it is out.

Questions

Which Python version does PythonMastery use?

Python 3.13 by default, everywhere on the site. In the online editor you can switch to Python 3.14, 3.12 or 3.11 from the status line above the output. The lessons, examples, Tutorial Lab, notebook and embedded code boxes always run Python 3.13, the version their outputs were checked on.

Can I run Python 3.14 online?

Yes. Open the editor, click the status line that says Python 3.13.2 Ready and choose Python 3.14. It is real CPython 3.14 compiled to WebAssembly, so new syntax such as t-strings works. Nothing is installed and there is no account.

Why are NumPy and pandas older on Python 3.11?

In the browser, packages with compiled parts have to be built for each release of Pyodide, the project that runs Python in the browser. Its last release for Python 3.11 came out in early 2024, so it carries NumPy 1.26 and pandas 1.5. A desktop install of Python 3.11 today would get newer versions, so some results can differ.

Can I install any package from PyPI?

Packages written in pure Python install from PyPI on every version. Packages with compiled parts install only if Pyodide has built them for that version. PyTorch and TensorFlow have no browser build at all. If a package is missing on one version but available on another, the editor says which one.