[Edu-sig] Introducing Python to Engineering Students

David MacQuigg macquigg at ece.arizona.edu
Tue Mar 11 03:28:21 CET 2008


I've been asked to give an intro to Python for a freshman class with 150 students at University of Arizona.  The class is taught in the Electrical and Computer Engineering Department, and is titled Computer Programming for Engineering Applications. The language is C (Hanly & Koffman, Problem Solving and Program Design in C).

I think a nice way to do this will be an application where we can show the advantages of both languages - the computation of Mandelbrot images http://en.wikipedia.org/wiki/Mandelbrot_set.  Python will provide the high-level "glue" which brings everything together in a nice programming environment, and C will provide the raw power for the loop that actually computes the pixels.  My initial tests show this loop running about 100 times faster in C than in Python.  

The challenge is to do this without overwhelming the students.  The plan is to make everything as simple as possible, just follow the instructions, except the loop itself, which the students will write in C, based on what I have written in Python.  See http://ece.arizona.edu/~edatools/ece175/projects/mandelbrots/mbrotHW.html.

Suggestions are welcome.  Has anyone done something like this before?  Can you improve on my code (I'm not a Python expert), or even suggest something entirely different?

There is one major piece I would like to add to what I have so far - output graphics.  This demo would really be cool if the students could see these glorious images appear on their screen instead of an array of numbers.  I looked at the Python Imaging Library http://www.pythonware.com/products/pil/index.htm, and I don't see any examples that I can work from in converting an array of numbers into an image, just a lot of dense reference material that assumes I already know these image data formats.  Maybe there is a simpler way.  Help from someone with experience in Python graphics would be most appreciated.

-- Dave 





More information about the Edu-sig mailing list