
The real beauty here is that the user controls how quickly they go through all the steps in the visualization. Should we encounter any bugs or simply want to tweak the code, all we do is click that edit button and then start the visualization again once we’ve made the changes we want.
Python tutor code#
Lastly, we have the “Edit this code” hyperlink directly underneath the code sample. If there’s any print output, then we can see that in the top right corner of the visualizer. The green and a red arrows point to the lines of code that have just been executed and that will be executed next, respectively.įor every line of code executed, the space on the right half of the visualizer draws out all of the frames storing variables and the objects to which those variables point (if any). Initially, we can click “Next >” to start the visualization, “Last >” to skip to the end, or drag the slider to view some point in between. There exists support for the various languages mentioned above, but I’m going to use Python 3.6 for this demo. Once on the code editor (linked above), we select a language. Let’s see a simple example with some explanation.
Python tutor pro#
Pro tip: just bookmark this page and not the home page. The home page provides a brief introduction and interactive demo, but if you’re not reading too carefully you may miss the hyperlink to the actual code editor and visualizer that reads, “ Visualize your code and get live help now”. This is an incredible tool for beginners looking to better understand how Python code is run, as well as more experienced programmers looking to refresh their understanding of how the code is executed. However, I’m not going to speak much to this feature since I believe the main value here is in visualizing the execution of your program.


There’s also a featuer allowing users to collaborate in real time to help each other. Don’t be fooled by the name… there’s no actual tutor! And despite the name, Python Tutor currently supports Python 2 and 3, C, C++, Java, JavaScript, TypeScript, and Ruby. Python Tutor’s online coding environment allows you to write code and visualize frame-by-frame how it gets executed by the computer. Luckily, there exists a free and easy-to-use web app for just that: Python Tutor.

This can help us better understand things like where and why bugs arise or how we might be able to optimize the performance of our code. A visualization of frame-by-frame code executionĪs programmers, it can often be very helpful to visualize what exactly the computer is doing under the hood.
