What is REPL? REPL is the language shell, the Python Interactive Shell. The REPL acronym is short for Read, Eval, Print and Loop.

The Python interactive interpreter can be used to easily check Python commands. To start the Python interpreter, type the command python without any parameter and hit the “return” key.

The process is:

  1. Read: take user input.
  2. Eval: evaluate the input.
  3. Print: shows the output to the user.
  4. Loop: repeat.

Related Course: Complete Python Programming Course & Exercises


You can check the version of Python you have installed by typing python without pressing enter, instead pressing the tab key. This will return the Python versions installed on your computer

➜  ~ python
python python2.7 python3.7 python3.7m python3-config python3m python3-pasteurize
python2 python3 python3.7-config python3.7m-config python3-futurize python3m-config python3-wsdump

To get more details on the version, you can type the command:

python --version

You should be using Python 3 or newer (2 is legacy).


REPL is the Interactive shell

To start the Python language shell (the interactive shell), first open a terminal or command prompt. Then type the command python and press enter.

Python then outputs some information like this (including the Python version):

$ python 
Python 3.7.5 (default, Nov 20 2019, 09:21:52)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.

After the symbols >>> you can type a line of Python code, or a command.

Each command at the prompt is evaluated by Python. If you would type, if it’s incorrect it returns an error.

>>> hello world
File "<stdin>", line 1
hello world
SyntaxError: invalid syntax

In the above example it’s incorrect because text must be between quotes.

>>> "hello world"
'hello world'
python interactive shell repl

On some versions of Ubuntu you need type python3 instead of python.

You can type all kinds of commands in the interactive shell. If you want to use it as calculator, just type your calculation:

>>> 128 / 8
>>> 256 * 4

Variables can be used in the Python shell too:

>>> width = 10
>>> height = 20
>>> size = width*height
>>> print(size)

Note: We’ll teach you how to start python programs in the next article.

How to Quit the Python Shell

If you started the Python interactive shell, you may be wondering how to exit it. There are several ways to quit the Python interactive shell (REPL).

One way is by typing exit(). This is calling the function exit, which is why the brackets in exit() must be written.

>>> exit()
➜ ~

A keyboard shotcut can be used to exit the shell too: Ctrl-D.

If you are a Python beginner, then I highly recommend this book.

Download exercises