Online Compiler, AI Tutor, and Visual Debugger for Python, Java, C, C++, and JavaScript

Python Tutor helps you do programming homework assignments in Python, Java, C, C++, and JavaScript. It contains a step-by-step visual debugger and AI tutor to help you understand and debug code.

Since 2010, over 20 million people in more than 180 countries have used Python Tutor to visualize over 300 million pieces of code. It is the most widely-used program visualization tool for CS education.

As a preview, here is a small example that visualizes recursion in Python:

Python 3.6
1def listSum(numbers):
2  if not numbers:
3    return 0
4  else:
5    (f, rest) = numbers
6    return f + listSum(rest)
7
8myList = (1, (2, (3, None)))
9total = listSum(myList)
line that just executed
next line to execute

Frames
Global frame
listSum
 
myList
 
listSum
numbers
 
f1
rest
 
listSum
numbers
 
f2
rest
 
Objects
function
listSum(numbers)
tuple
01
1
 
tuple
01
2
 
tuple
01
3None

You can also ask an AI tutor for help in understanding your code and visualization:

Here are some examples of how this tool visualizes Java, C, and C++ code: