Course contentsShow
Python
Lesson 10 of 1,2891. FoundationsFree lesson

The Python REPL

Using the interactive interpreter for quick experiments.

The Python REPL

What you'll learn: How to use Python's interactive interpreter to test code instantly without creating files.

What is the REPL?

REPL stands for Read-Eval-Print-Loop. It's Python's interactive mode where you can type code and see results immediately. Think of it like a calculator: you type something in, press Enter, and instantly get an answer.

When you open your terminal (Command Prompt on Windows, Terminal on macOS/Linux) and type python or python3, you enter the REPL. You'll see a prompt that looks like >>> — this is Python waiting for you to type something.

Why Use the REPL?

The REPL is perfect for quick experiments. Instead of writing a full program in VS Code, saving it, and running it just to test one small idea, you can:

  • Try out a calculation
  • Test how something works
  • Check if you remember the exact way to write something
  • Experiment without consequences (nothing gets saved)

Analogy: The REPL is like a scratch pad. Your full programs in VS Code are like formal notebooks. Sometimes you just need to scribble a quick note or do mental math — that's when you use the scratch pad instead of opening your formal notebook.

When to Use It

Use the REPL when you want to answer quick questions: "What happens if I...?" or "Does Python let me...?" It's especially helpful when learning because you get instant feedback.

To exit the REPL, type exit() or press Ctrl+D (macOS/Linux) or Ctrl+Z then Enter (Windows).

Key Takeaway: The Python REPL is your interactive playground for testing ideas instantly — type code, see results immediately, no files needed.