Skip to main content
When you write a full Python script and run it, you have to wait for the entire file to execute before you see any output. For small programs that is fine. But when you are building AI applications, processing data, or exploring an API response, you want to see results immediately after each step — adjusting, inspecting, and iterating as you go. That is exactly what interactive Python gives you. It is the development style used throughout this course, and once you experience it you will rarely want to go back to running whole files at once.

Two ways to run Python interactively

The Python REPL

The REPL (Read–Eval–Print Loop) is the simplest interactive Python experience. Open a terminal and type:
You enter a live Python session where every line you type is executed immediately:
The REPL is useful for quick calculations and one-off checks, but it has a limitation: your code exists only in memory. When you close it, everything is gone. VS Code’s Interactive Window gives you the best of both worlds: you write organised code in a .py file, but you can run any selection of it instantly in an interactive panel — with full output, variable persistence, and even inline visualisations. This is the workflow used throughout this course.
The Interactive Window is powered by the Jupyter extension. Make sure you have it installed (covered in the Setup page) before continuing.

Set up the Interactive Window

1

Install ipykernel

With your virtual environment active, install the IPython kernel:
2

Enable Shift + Enter execution

  1. Open Settings with Ctrl/Cmd + ,
  2. Search for execute selection
  3. Find Jupyter › Interactive Window › Text Editor: Execute Selection
  4. Check the box to enable it
With this setting enabled, highlighting any code in a .py file and pressing Shift + Enter will run it in the Interactive Window panel.

Your first interactive session

1

Create a new file

Create a file called interactive_demo.py in your project folder.
2

Write some code

3

Run it interactively

Click on the first line, then press Shift + Enter. An Interactive Window opens on the right side of the editor and shows the output for that line.Keep pressing Shift + Enter to run line by line, or highlight a block of code and press Shift + Enter to run it all at once.

What makes the Interactive Window powerful

Variables persist across executions

Once you assign a variable in the Interactive Window, it stays in memory for your entire session. You do not have to re-run earlier lines every time you want to use a variable further down the file.

Run only what you need

You can highlight any subset of your code — a single expression, a few lines, or a complete function — and run just that selection. This means you can test a new idea on line 50 without re-executing lines 1 through 49.

See rich output

The Interactive Window renders output more richly than a plain terminal. DataFrames display as formatted tables, matplotlib charts appear inline, and long outputs are scrollable.

Interactive workflow for AI development

When you are working with AI and data, this workflow is particularly valuable:
Run each block separately. If something looks wrong in step 2, fix it and re-run just that block — no need to restart from the beginning.
Think of the Interactive Window as cooking and tasting as you go, rather than waiting until the entire meal is prepared before trying any of it. You catch problems early and adjust in real time.

Quick reference

Start learning Python

Your environment is ready. Let’s dive into Python fundamentals!