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.

As of Dec 2013, 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. Over 6,000 pieces of Python code are executed and visualized every day.

Users include self-directed learners, students taking online courses from Coursera, edX, and Udacity, and professors in dozens of universities such as MIT, UC Berkeley, and the University of Washington.

As a demo, 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.

You can also visualize execution in the IPython shell in interactive mode. Watch this one-minute overview:

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]

EMBED visualizations in digital textbooks

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

These visualizations have also been embedded within two other Web-based Python textbook projects: How to Think Like a Computer Scientist: Interactive Edition and Computer Science Circles. These textbooks collectively attract around 16,000 unique viewers per month and are being used in at least 25 universities around the world.

In addition, instructors have embedded Online Python Tutor visualizations into LMS platforms such as Moodle and edX.

SHARE visualizations online

To share your current visualization, click the “Generate URL” button (at the bottom of this page) and paste that URL link in an email, social networking post, or forum question. When recipients click on that link, they will see your exact visualization. This feature provides a more effective way for students to seek assistance than copying and pasting code snippets.

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.

More Details:

Other Variants: