Installing Python is easy, but maybe you're on a smartphone/tablet, are on a library computer that doesn't let you install software, or can't install Python for some other reason. This article has a list of 17 free Python interpreters and interactive shells (also called REPLs) that you can access from a web browser.
There are some downsides to using a browser-based Python interpreter. You won't be able to read or write files with the
open() function or make network connections. You might not be allowed to have long-running programs or programs that use a lot of memory. And you won't be able to install third-party modules such as NumPy, Pandas, Requests, PyAutoGUI, or Pygame (though some will have these modules pre-installed.) Some other Python features might be disabled; you'll have to check with them individually. Some of these require you to sign up for a free account. You can use 10 Minute Email to create disposable email accounts if you don't want to deal with spam.
However, you'll still be able to practice writing Python code. The game, simulation, and digital art projects in my book The Big Book of Small Python Projects will still work in these online interpreters. You'll also be able to enter the text-based game projects from Invent Your Own Computer Games with Python and the encryption and code-breaking projects from Cracking Codes with Python.These books are free to read online through a Creative Commons license.
Here's a curated list of browser-based Python interpreters. This isn't a hastily put together clickbait blog post; I've examined each of these and listed them in order of my personal preference.
My favorite browser-based Python file editor is Python Tutor. Python Tutor offers a built-in debugger that lets you execute one line at a time and inspect how the program executes. Not only that, but it also records the state of the program at each step, so you can also step backwards. This is a feature most debuggers don't have.
PythonAnywhere is one of the most popular browser-based interpreters. You must sign up first, but free accounts are available. You'll be able t to store your Python scripts, or just use their IPython interactive shell without having to log in. Their service allows you to read and write files to a virtual hard drive, and they have many popular Python third-party modules already installed. They have several different Python versions available, and PythonAnywhere is also used for the interactive shell on the Python.org website.
You can avoid this by downloading Brython and running it off of your computer. This way you won't need an internet connection after downloading Brython. First, download Brython-3.11.0.zip from the Brython release page on their GitHub account (or whatever the latest version you see on that page). Unpack the Brython-3.11.0 folder inside the zip. Create a new text file named console.html (or any name with a .html extension you choose) and put the following text into it:
When you open this .html file on your computer, you'll have a working Python interactive shell.
Your Google or GMail account can give you access to a Jupyter Notebooks-style REPL with generous memory and runtime limits.
Trinket is an education-focused site. You need to sign up for a free account to use it, but their interactive shell also supports Turtle, Matplotlib, and other modules that many online REPLs don't.
Python Fiddle is a bare bones editor that lets you create and run Python scripts. Their user interface is a bit unwieldy, but it is rather straightforward.
Ideaone has a rich editor and supports several programming languages besides Python (even older languages like Pascal, Fortran, Prolog, and Cobol, and esoteric programming languages like Brainfuck and Intercal). There's only the editor that lets you write and run programs (with a 5 second runtime limit), but no interactive shell. I think Ideaone is better if you want to practice in less popular languages, rather than use it on a common basis for Python.
SymPy Live Shell
A Jupyter Notebooks-style REPL with a small user interface that is fine for casual examples. It uses JupyterLite to run JupyterLab entirely in your browser rather on their servers.
A decent editor that has a nice user interface without being too overwhelming. The runtime and memory limits seem quite generous too. I'd recommend this one.
W3Schools Python Shell
W3Schools has a straightforward Python editor with basic syntax highlighting. It has a runtime limit of about 10 seconds, though it doesn't report an error if your program goes over it. It's fine for simple examples.
Python Principles Online Python Interpreter
A simple file editor, but I had trouble getting it to run anything more than a toy example.
Online Python Beta
A simple and straightforward Python editor that runs the code on their back-end. Good for toy examples.
A simple and straightforward editor with generous runtime limits.
This looks like a hobbyist project with a minimal editor and 5 second runtime limit. There are compilers for other languages, but the website is hard to navigate.
https://portablepython.com/ (NOT RECOMMENDED
This isn't a browser-based REPL, but rather a .exe file to run Python on Windows without having to install anything. However, the page hasn't been updated since 2013 (and Python 3.2), and the download pages don't use HTTPS. I recommend against using this software due to the possibility of malware.
Visual Studio Code Online
Visual Studio Code is an Electron app, meaning that it can run as a regular desktop app or a browser-based app. The browser version is a bit limited, and navigating this online IDE has a steeper learning curve than the other online interpreters. Still, if you're willing to dive into it or already have experience with Visual Studio Code, you can use this browser-based version.