Visualize
code execution

for Python, Java, C, C++, and JavaScript

Start Visualizing
25+ million users since 2010
500+ million visualizations
180+ countries
10,000+ schools using it

Learn Programming Visually

Python Tutor is the only tool that lets you write code in a web browser and see what happens step-by-step as the computer runs it. It visualizes variables, objects, pointers, data structures, and stack frames. These visuals help students to debug their homework, teachers to explain concepts, and programmers to prepare for job interviews. You can also chat with an AI Tutor if you need help understanding or debugging your code.

Despite its historical name, Python Tutor visualizes Python, Java, C, C++, and JavaScript, which are the most popular languages in both schools and workplaces. Since 2010 it has been used by over 25 million people from over 180 countries and in computer science (CS) classes at thousands of universities including MIT, Harvard, Princeton, UC Berkeley, Tsinghua, and the IITs.

Try it out
Python code showing recursive listSum function Visualization showing stack frames and tuple objects
👤 You
Summarize this step in the visualization for me
🤖 AI Tutor

The visualization (stack trace) summarizes the current state of function calls in your Python program. Here's a concise summary:

  1. Current Execution: The top of the stack shows that the listSum function is currently executing at line 6.
  2. Recursive Call: The second entry indicates that this listSum call was invoked by another instance of listSum, also at line 6. This shows that the function is recursive and working to compute the sum of the nested tuple.
  3. Main Entry Point: Below the recursive calls, the <module> entry signifies that the initial call to listSum(myList) was made from the main program block at line 9.
  4. Local Variables: For the currently executing listSum, we can see:
    • numbers is (2, (3, None)), the current input being processed.
    • f is 2, the first item of that input.
    • rest is (3, None), the remainder of the input.

This stack trace visualization helps you understand the function's execution flow, showing how it recurses and manages state with local variables throughout the process.

Chat with a Free AI Tutor

Ask a free personalized AI tutor for help in understanding your code and visualization. Unlike ChatGPT or other tools, Python Tutor's AI can directly see your code, errors, and visualizations, so it can give better help. If you're teaching, you can use AI to generate customized code examples or programming assignments for your students.

Chat with AI

Impact

Python Tutor is an online compiler, AI tutor, and visual debugger for Python, Java, C, C++, and JavaScript. Since 2010 over 25 million people in more than 180 countries have used it to visualize over 500 million pieces of code, making it the most widely-used visualization tool for CS education. The live map above shows 10,000 to 20,000 people using it daily right now.

Students: Ace Your Classes

  • Deeply understand code by forming an accurate mental model of how it executes
  • Fix bugs in your homework and class projects
  • Visualize content from introductory programming and DSA (Data Structures & Algorithms) tutorials
  • AI Tutor explains visualizations to you and helps you debug your code
Start visualizing now

Teachers: Engage Your Students

  • Do live coding in front of your class and walk through step-by-step visualizations
  • Have students guess what happens at each step and do other active learning
  • Create engaging lessons based on interactive visualizations
  • AI assistant helps you create easy-to-visualize code examples and assignments
Free teacher mode

Programmers: Get That Job!

  • Prepare for technical interviews by building a strong mental model of code execution
  • Visualize DSA (Data Structures & Algorithms) concepts that interviewers ask about
  • Learn a new programming language by analogy to ones you already know
  • AI Tutor teaches you more advanced programming concepts on-demand
Start visualizing now