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()orquit(), 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!
Get Your Code: Click here to get the free sample code that you’ll use to learn about interacting with Python.
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 PythonTest your knowledge of Python's REPL, running scripts from files, using IDEs and code editors, and Jupyter Notebooks.
Python for Beginners Live Course: Want to take your first steps with Python alongside an instructor? In Real Python’s Python for Beginners live course, you build real programs in a small group, with live feedback when you get stuck. Join the waitlist to hear about the next dates.
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:
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
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:
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.
Note: If you need additional help to get to this point, then you can check out the How to Install Python on Your System: A Guide tutorial.
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 ]
