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:VS Code Interactive Window (recommended)
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
- Open Settings with
Ctrl/Cmd + , - Search for execute selection
- Find Jupyter › Interactive Window › Text Editor: Execute Selection
- Check the box to enable it
.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:Quick reference
Start learning Python
Your environment is ready. Let’s dive into Python fundamentals!