LEARN programming by visualizing code execution

Online Python Tutor is a free educational tool created by Philip Guo that helps students overcome a fundamental barrier to learning programming: understanding what happens as the computer executes each line of a program's source code. Using this tool, a teacher or student can write a Python program in the Web browser and visualize what the computer is doing step-by-step as it executes the program.

Over 500,000 people in over 165 countries have used Online Python Tutor to understand and debug their programs, often as a supplement to textbooks, lecture notes, and online programming tutorials.

For instance, here is a visualization showing a program that recursively finds the sum of a (cons-style) linked list. Click the “Forward” button to see what happens as the computer executes each line of code.

Read the research paper – Philip J. Guo. Online Python Tutor: Embeddable Web-Based Program Visualization for CS Education. In Proceedings of the ACM Technical Symposium on Computer Science Education (SIGCSE), March 2013. [BibTeX]

SHARE live visualization sessions

Click the “Start a shared session” button to allow an instructor or friend to join your session. You can chat about your code and navigate the visualization together to get live, real-time tutoring. Watch this one-minute video demo:

Also, you can click the “Generate permanent link” button (at the bottom of this page) and paste that link in an email, social networking post, or forum question. When recipients click on your link, they will see the exact visualization you've created.

For example, clicking this link brings you directly to step 44 of 57 in a program that finds prime numbers using the Python for-else construct.

EMBED in any Web page

Using a single line of JavaScript code, you can embed an Online Python Tutor visualization within any Web page (as shown in the “Learn” box above). The screenshot below shows a visualization embedded within the online textbook for the introductory CS course at UC Berkeley (CS61A):

More Details:

  • Online Python Tutor runs Python 2.7 and 3.3, hosted on any CGI-capable Web server.
  • Main technologies: Python with bdb for the backend; HTML/CSS/JavaScript with jQuery, D3.js, jsPlumb, TogetherJS, and Ace for the frontend
  • Free, open-source BSD-licensed code on GitHub
  • View the project documentation online.
  • Want to help out? I have lots of project ideas. Email philip@pgbovine.net to learn more.

Other Variants: