DevHireLab
Tutorials
BootcampProblemsCode SimulatorAI InterviewSoonContact
DevHireLab
Tutorials
BootcampProblemsCode SimulatorAI InterviewSoonContact
Getting Started
01
What is Python and Why Learn It in 2026
02
Installing Python on Windows, Mac, and Linux
03
Setting up VS Code / PyCharm for Python
04
Understanding the Python Interpreter and REPL
05
Writing and Running Your First Python Program
06
Python Syntax and Indentation Rules
Variables and Data Types
01
Variables and Naming Conventions in Python
02
Numbers in Python (int, float, complex)
03
Strings and String Methods in Python
04
Booleans in Python
05
Type Conversion / Casting in Python
06
Understanding the None Type in Python
Operators
01
Arithmetic Operators in Python
02
Comparison Operators in Python
03
Logical Operators in Python
04
Assignment Operators in Python
05
Bitwise Operators in Python
06
Identity (is) and Membership (in) Operators
07
Walrus Operator (:=) in Python
Input, Output & Strings
01
input() and print() Functions in Python
02
f-strings and String Formatting in Python
03
String Slicing and Indexing in Python
04
Common String Methods (split, join, strip, replace)
05
Escape Characters in Python Strings
Control Flow
01
if, elif, else Statements in Python
02
Nested Conditionals in Python
03
for Loops in Python
04
while Loops in Python
05
break, continue, and pass Statements
06
Loop with else Clause in Python
07
match-case (Structural Pattern Matching)
Data Structures
01
Python Lists: Creation, Indexing, Slicing, Methods
02
Python Tuples and Immutability
03
Python Sets and Set Operations
04
Python Dictionaries: Keys, Values, and Methods
05
List Comprehensions in Python
06
Dictionary & Set Comprehensions in Python
07
Working with Nested Lists and Dictionaries
Functions
01
Defining and Calling Functions in Python
02
Function Arguments: Positional, Keyword, Default
03
*args and **kwargs in Python
04
Return Statements in Python Functions
05
Lambda Functions in Python
06
Recursion in Python
07
Variable Scope: Local, Global, Nonlocal
08
Docstrings and Function Annotations
Functional Programming Basics
01
map(), filter(), and reduce() in Python
02
Closures in Python Explained
03
Python Decorators: Basic to Advanced
04
Generators and yield in Python
Object-Oriented Programming (OOP)
01
Classes and Objects in Python
02
The init Constructor in Python
03
Instance vs Class Variables in Python
04
Inheritance in Python (Single, Multiple, Multilevel)
05
Polymorphism in Python
06
Encapsulation in Python
07
Abstraction in Python with the abc Module
08
Magic/Dunder Methods in Python
09
Static and Class Methods in Python
10
The @property Decorator in Python
11
Python Dataclasses Explained
Error Handling
01
try, except, finally in Python
02
Handling Multiple Exceptions in Python
03
Raising Custom Exceptions in Python
04
Understanding Python's Exception Hierarchy
05
Assertions in Python
File Handling
01
Reading and Writing Text Files in Python
02
Working with the with Statement in Python
03
Working with CSV Files in Python
04
Working with JSON Files in Python
05
Working with Directories (os, pathlib) in Python
Modules and Packages
01
Importing Built-in Modules in Python
02
Creating Your Own Modules in Python
03
Understanding Packages and init.py
04
Python Standard Library Overview
05
Installing Packages with pip
Advanced Core Concepts
01
Iterators and Iterables in Python
02
Context Managers in Python (with, contextlib)
03
Multithreading Basics in Python
04
Multiprocessing Basics in Python
05
Asyncio Basics: async/await in Python
06
Memory Management and Garbage Collection in Python
07
Type Hints in Python (typing module)

Understanding the Python Interpreter and REPL

You've probably typed python into a terminal and landed in a strange little prompt that just sits there waiting for input. That's the Python REPL, and understanding how it works — alongside the python interpreter that powers it — is one of those foundational things that makes everything else about learning Python click faster.

What is the Python Interpreter?

Programming languages generally fall into two camps: compiled and interpreted. A compiled language (like C or Rust) gets translated entirely into machine code ahead of time, producing a standalone executable. Python doesn't work that way. It's an interpreted language, which means the python interpreter reads your code and executes it directly, translating it into instructions the computer can run as it goes.

This matters practically because it changes your feedback loop. There's no separate "compile" step waiting between you and running your code — you write it, and the interpreter runs it, right then.

Two ways the interpreter executes code

The interpreter can operate in two different modes:

  • Script mode — you run an entire file at once, typically something with a .py extension:

python my_script.py
  • Interactive mode — you launch the interpreter with no file argument, and it drops you into a prompt where you type code one line (or block) at a time, see the result immediately, and keep going.

Interactive mode is where the REPL lives, and it's what the rest of this article focuses on.

CPython, the standard implementation

When people say "the Python interpreter," they usually mean CPython — the reference implementation of Python, written in C, maintained by the Python core team, and what you get when you download Python from python.org. Other implementations exist (PyPy, for instance, optimized for speed through just-in-time compilation), but CPython is what almost everyone uses day to day, and it's the one this article assumes.

What is the REPL? (Read-Eval-Print Loop)

So, what is REPL in Python, exactly? REPL stands for Read-Eval-Print Loop, and the name describes exactly what it does, step by step:

  • Read — it reads the line (or block) of code you typed.

  • Eval — it evaluates that code.

  • Print — it prints the result to your screen.

  • Loop — it goes back to step one and waits for your next input.

That cycle repeats for as long as your session stays open.

Launching the REPL

Open a terminal and type:

python
# or, depending on your system
python3

You'll land on a prompt that looks like this:

>>>

That >>> is the primary prompt — it means the interpreter is ready for a fresh line of input. If you start typing something that isn't finished yet (like the first line of a function), you'll see a different prompt:

...

That's the secondary prompt, and it means the interpreter is still waiting for more input to complete the current block.

Why it's called an "interactive shell"

The Python REPL is often called the python interactive shell because it behaves like a conversation: your keyboard is the input, your screen is the output, and there's no file being saved anywhere in between. You type a line, get a response, type another line, get another response. It's the fastest way to test an idea in Python without the overhead of creating and running a file.

Using the REPL: Practical Examples

The most natural way to get comfortable with the REPL is to just start typing things into it.

Using it as a calculator
>>> 7 * 6
42
>>> 100 / 4
25.0
Variable assignment
>>> name = "Alex"
>>> greeting = f"Hello, {name}!"
>>> greeting
'Hello, Alex!'

Notice you don't need print() at the REPL — typing an expression by itself automatically displays its result. That's a REPL-specific behavior; it won't happen the same way in a script.

Handling multi-line blocks

Try typing a for loop:

>>> for i in range(3):
...     print(i)
...
0
1
2

The ... secondary prompt keeps appearing until you press Enter on a blank line, signaling the block is finished and ready to run.

Useful python REPL commands and shortcuts
  • Command history — press the Up and Down arrow keys to cycle back through what you've typed, instead of retyping it.

  • The underscore operator (_) — after any expression, the REPL stores its result in a special variable named _, so you can reuse it:

>>> 15 + 27
42
>>> _ * 2
84
The REPL's big limitation

Nothing you type in the REPL is saved anywhere. Close the session, and it's gone — there's no file left behind. That makes it perfect for testing an idea, checking how a function behaves, or trying out unfamiliar syntax, but it's the wrong tool for building anything you actually want to keep. For that, you need script mode.

REPL vs. Script Mode: When to Use Each

Script mode: for real programs

Script mode is what you use for anything meant to be run more than once, shared, or built into something bigger. A typical script includes the if __name__ == "__main__": pattern, which lets a file behave differently depending on whether it's being run directly or imported by another file:

def main():
    print("Running as a script")

if __name__ == "__main__":
    main()

This pattern is standard in real Python projects — it keeps code reusable while still giving you a clear entry point when running the file directly.

REPL: for exploration

Use the REPL when you want a fast answer to a small question: "What does this method return?" "Does this list comprehension work the way I think it does?" "What's the syntax for this again?" It's also genuinely useful for debugging — you can inspect variables and try fixes on the fly without editing and rerunning a whole file.

How they work together

In a normal workflow, these two modes aren't competitors — they're complementary. You might test a tricky piece of logic in the REPL first, confirm it behaves the way you expect, and then copy it into your script once you're confident it's right. Experienced developers move between the two constantly.

5. Beyond the Standard REPL: Alternatives Worth Knowing

IDLE

IDLE is a simple GUI-based shell that ships bundled with most Python installations. It wraps the same interactive interpreter in a basic window with some added conveniences, like syntax highlighting. It's a fine starting point, though most working developers move on to something more capable fairly quickly.

IPython vs standard REPL

IPython is a significantly more feature-rich interactive shell, especially popular in data science work. It adds rich tab-completion, "magic commands" (special commands prefixed with %, like %timeit for quick benchmarking), and better support for inspecting objects. If you're planning to work with libraries like pandas or NumPy, IPython (or the Jupyter notebooks built on top of it) is worth installing early.

The new python REPL 3.13 and later

If you're using Python 3.13 or newer, you're already getting a meaningfully upgraded standard REPL compared to older versions. The interpreter now supports genuine multi-line editing — you can arrow up to a previous function or loop and edit the whole block at once, rather than retyping it line by line. It also added colorized output, direct commands like exit and help without needing parentheses, and a dedicated history browser you can open with F2. Python 3.14 went a step further, adding real-time syntax highlighting and import autocompletion as you type. These changes closed a lot of the gap that used to make people reach for IPython just for basic quality-of-life features.

Running the REPL inside VS Code

If you set up VS Code for Python using the steps from the previous article in this series, you already have quick access to a REPL without leaving your editor — the integrated terminal lets you launch python directly, and it respects whichever interpreter and virtual environment you've selected for the project. That means you can test a snippet in the REPL and immediately confirm it's using the exact same environment your actual script will run in — no more guessing which Python installation is answering your questions.

PREVIOUSNEXT LESSON