Algebra and Programming with VPython

Posted September 4, 2011

by Lensyl Urbano

Computer programming is the place where algebra comes to life. Students seem to get really excited when they write even the simplest instructions and see the output on the screen. I’m not sure exactly why this is the case, but I suspect it has something to do with being able to see the transition from abstract programming instructions to “concrete” results.

So I’ve decided to supplement my Algebra classes with an introduction to programming. I’m using the Python programming language, or, more specifically, the VPython variant of the language.

Why VPython? Because it’s free, it’s an easy-to-use high-level language, and it’s designed for 3d output, which seems to be somewhat popular these days. The oohs and aahs of seeing the computer print the result of a+b turn into wows when they create their first box. I’ve used the language quite a bit myself, and there are a lot of other interesting applications available if you search the web.

VPython was created to help with undergraduate physics classes, but since it was made to be usable by non-science majors, it’s really easy for middle and high school students to pick up. In fact, NCSU also has a distance education course for high school physics teachers. They also have some instructional videos available on YouTube that provide a basic introduction.

Image from a game created by middle school student Ryan W.

I use VPython models for demonstrations in my science classes, I’ve had middle school students use it for science projects, and I’ve just started my middle school algebra/pre-algebra students learning it as a programming language and they’re doing very well so far.

What I hope to document here is the series of lessons I’m putting together to tie, primarily, into my middle school algebra class, but should be useful as a general introduction to programming using VPython.

Getting VPython

You’ll need to install Python and VPython on your system. They can be directly downloaded from the VPython website’s download page for Windows, Macintosh or LINUX.

Running a Python program.

Once they’re installed, you’ll have the IDLE (or VIDLE) program somewhere on your system; a short-cut is usually put on the desktop of your Windows system. Run (double-click) this program and the VPython programming editor will pop up any you’re ready to go. You can test it by typing in something simple like:

a = 1
b = 2
c = a + b
print c

Then you run the program by going through the Run–>Run Module in the menu bar.

Which should cause a new window to pop up with:

Python 2.7.1 (r271:86882M, Nov 30 2010, 09:39:13) 
[GCC 4.0.1 (Apple Inc. build 5494)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================

Even better might be to test the 3d rendering, which you can do with the following program:

from visual import *


which creates the following exciting image:

A box created with VPython. It looks much more interesting if you rotate it to see it in perspective.

To rotate the view, hold down and drag the right mouse button. To zoom in or out, hold down the right and left buttons together and drag in and out.

A rotated, zoomed-out view of a box.


Lesson 1: Variables, Basic Operations, Real and Integer Numbers and the First Box.

Lesson 2: Creating a graphical calculator: Coordinates, lists, loops and arrays: A Study in Linear Equations

Citing this post: Urbano, L., 2011. Algebra and Programming with VPython, Retrieved January 20th, 2017, from Montessori Muddle: .
Attribution (Curator's Code ): Via: Montessori Muddle; Hat tip: Montessori Muddle.

Leave a Reply

You must be logged in to post a comment.

Creative Commons License
Montessori Muddle by Montessori Muddle is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.