Python Tutor - Visualize Code Execution (original) (raw)

Python Tutor is designed to imitate what an instructor in an introductory programming class draws on the blackboard:

Instructors use it as a teaching tool, and students use it to visually understand code examples and interactively debug their programming assignments.

Quick links:

Demo

The screenshot below shows how a typical user (either an instructor or a student) would interact with it:

The user can navigate forwards and backwards through all execution steps, and the visualization changes to match the run-time state of the stack and heap at each step. In this example, the user would see their custom LinkedList data structure getting incrementally built up one Node at a time via recursive calls to init() until the base case is reached when n==0.

Language Support

Despite its name, Python Tutor is also a widely-used web-based visualizer for Java that helps students to understand and debug their code. It visualizes the majority of object-oriented programming concepts taught in introductory college courses (e.g., CS1 and CS2), high school AP Computer Science, and intermediate-level Java programming.

Python Tutor is also a widely-used web-based visualizer for C and C++ meant to help students in introductory and intermediate-level courses. It usesValgrind to perform memory-safe run-time traversal of data structures, which lets it display data more accurately than gdb or printf debugging. For instance, it can precisely visualize critical concepts such as pointers, uninitialized memory, out-of-bounds errors, nested arrays/structs/unions, type punning, and bit manipulation.

Lastly, it also supports visualizing standalone JavaScript execution, but not web frontend code that does DOM manipulation on webpages.

Reporting Bugs

The issue you're encountering is likely listed in this document. If you're sure it's not, use the "Generate permanent link" button to make a URL of your code. Describe the expected behavior when running that code on your computer and how it differs from Python Tutor, thenfill out this Google Formto report your bug or security issue.