Sunday, March 31, 2013

Online Python Tutor looks quite interesting

By Vasudev Ram

Online Python Tutor by Philip Guo is a web-based tool to let you enter Python code and visualize it as it executes.

I went through the steps of the example on the home page.

The best way to understand what it is about it to try it, so use the links above, but I'll just add a few excerpts from the Online Python Tutor site:

The headline for the site is:

"LEARN programming by visualizing code execution"

[ Online Python Tutor is a free educational tool 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 directly in the web browser and visualize what the computer is doing step-by-step as it executes the program. ]

[ So far, over 200,000 people have used Online Python Tutor to understand and debug their programs, often as a supplement to learning from textbooks, lecture notes, and online programming tutorials.

In addition, instructors in over a dozen universities such as MIT, UC Berkeley, UC Davis, the University of Washington, the University of Toronto, the University of Waterloo, Luther College, and Swarthmore College have used it for teaching introductory computer science and programming courses. ]

[ 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). ]

[ 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 is a more effective way for students to seek assistance than copying-and-pasting code snippets. ]

I tried the Generate URL option, and here is the resulting URL.

[ Online Python Tutor supports Python 2.7 and 3.2, hosted on either a CGI-capable web server or on Google App Engine

Main technologies: Python with bdb for the backend; HTML/CSS/JavaScript with jQuery, D3.js, jsPlumb, and CodeMirror for the frontend

Free, open-source BSD-licensed code on GitHub ]

It has a few restrictons: for example, no file I/O, and imports of Python modules are restricted to a few modules. But those are understandable for an online interactive Python tool. IMO, it is still a good tool for learning Python online, at least for the algorithmic and logic aspects. You can learn a lot of programming without using any modules, just with the basic language.

Online Python Tutor has got some 30 to 40 Python code examples which you can try, modify and visualize.

- Vasudev Ram - Dancing Bison Enterprises

1 comment:

SonOfLilit said...

I have used this syccessfully and repeatedly in a classroom.

I use it as a lecturing aide, showing exactly what happens e.g. when the following code is invoked:

a = 1
b = a
a = 2
print b
# as opposed to
a = [1]
b = a
a[0] = 2
print b

I also give it to my students that they may experiment freely. Some use it as an aide to understanding, some as a debugging tool, and some solve all their exercises with it and only then copy the solutions into a regular text editor.

A game I like to play is to put a piece of hard-to-understand code in it, then ask a student what will change on the screen when I press "forward" - including to which line the red arrow is going to move, what will be added if any to the output textbox and how the memory will change. Then we press forward and check his understanding against reality. Rinse and repeat. This builds the ability to execute code in your head, called "reading ability" in strategy board games, which is perhaps the most important skill to teach a beginner to programming.