MICRO TOOL DECK
FREE

Python Tutor – Visualize Code Execution, Memory & Variables

Tip: Write or edit code below and click "Visualize Execution" to step through variables, stack frames, heap pointers, and console output.
Language: Python 3.12
1
Step 1 of 1
Starting execution...
Code Execution Python 3.12
▶ Line that just executed
▶ Next line to execute
Program output (stdout)
(no output yet)
Stack Frames Call Stack
Heap Memory Objects & Structures

Understanding Program Execution with Python Tutor

What happens during line-by-line execution?

As a program runs, each statement updates variables and control flow in sequence. Local variables and active function calls live inside stack frames, while lists, dictionaries, objects, and arrays are stored in heap memory.

What are Stack Frames?

A stack frame (activation record) is pushed onto the call stack whenever a function runs. It holds that call's parameters and local variables, then pops off the stack as soon as the function returns.

How does Object Aliasing work?

In Python and JavaScript, assigning an existing list or object to another variable (such as b = a) does not duplicate the data. Both variables hold references pointing to the exact same object on the heap.

Why visualize Pointer Arrows?

Pointer arrows connect stack variables directly to their heap objects, making mutability, recursion, linked lists, and shared references much easier to debug and learn.

Link copied to clipboard!