There are multiple ways of interacting with Python, and each can be useful for different scenarios. You can quickly explore functionality in Python’s interactive mode using the built-in Read-Eval-Print Loop (REPL), or you can write larger applications to a script file using an editor or Integrated Development Environment (IDE).

By the end of this tutorial, you’ll understand that:

  • Python’s REPL reads, evaluates, and prints each line that you type into the interpreter, which makes it the quickest way to try out short snippets of code.
  • You can leave the REPL by typing exit() or quit(), and in Python 3.13 and later you can usually drop the parentheses.
  • A Python script is a plain text file that you run by passing its name to the interpreter, as in python3 hello.py.
  • IDLE comes with most Python installations and combines a REPL, an editor, and a debugger, so you can write and run scripts in one place.
  • Jupyter Notebooks run your code in small cells, and online interpreters let you try Python in your browser without installing anything.

Before working through this tutorial, make sure that you have a functioning Python installation at hand. Once you’re set up with that, it’s time to write some Python code!

Take the Quiz: Test your knowledge with our interactive “Interacting With Python” quiz. You’ll receive a score upon completion to help you track your learning progress:


Interactive Quiz

Interacting With Python

Test your knowledge of Python's REPL, running scripts from files, using IDEs and code editors, and Jupyter Notebooks.

Hello, World!

There’s a long-standing custom in computer programming that the first code written in a newly installed language is a short program that displays the text Hello, World! to the console.

In Python, running a “Hello, World!” program only takes a single line of code:

Language: Python
print("Hello, World!") 

Here, print() will display the text Hello, World! in quotes to your screen. In this tutorial, you’ll explore several ways to execute this code.

Running Python in Interactive Mode

The quickest way to start interacting with Python is in a Read-Eval-Print Loop (REPL) environment. This means starting up the interpreter and typing commands to it directly.

When you interact with Python in this way, the interpreter will:

  • Read the command you enter
  • Evaluate and execute the command
  • Print the output (if any) to the console
  • Loop back and repeat the process

The interactive session continues like this until you instruct the interpreter to stop. Using Python in this interactive mode is a great way to test short snippets of Python code and get more familiar with the language.

Starting the Python Interpreter

When you install Python using the Python install manager, the Start menu shows a program group labeled Python with an entry for each runtime you’ve installed. The label may vary depending on the particular installation you chose. Click on that item to start the Python interpreter.

Alternatively, you can open your Command Prompt or PowerShell application and type the py command to launch it:

Language: Windows PowerShell
PS> py 

To start the Python interpreter, open your Terminal application and type python3 to launch it from the command line:

Language: Shell
$ python3 

If you’re unfamiliar with this application, then you can use your operating system’s search function to find it.

After pressing Enter, you should see a response from the Python interpreter similar to the one below:

Language: Python
Python 3.15.2 (main, Oct 26 2026, 14:06:56) [Clang 23.1.3 ] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 

If you’re not seeing the >>> prompt, then you’re not talking to the Python interpreter. This could be because Python is either not installed or not in the path of your terminal window session.

Read the full article at https://realpython.com/interacting-with-python/ »


[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]