[Edu-sig] Introducing Python to Engineering Students

David MacQuigg macquigg at ece.arizona.edu
Tue Mar 11 22:57:58 CET 2008

Many thanks for the quick and very helpful responses!!

At 08:00 PM 3/10/2008 -0700, kirby urner wrote:

>Just in case you want to look at an "all Python" solution down to the
>pixel level (using PIL):

Very nice!!  I like the clear concise explanation of fractals.  I'll add this link to whatever I put together.

I like the way you construct the color palette, simple but effective.  I'll have to play around with some more high-resolution images to see if I still get such nice colors.  I see you have a link on creating palettes, but it is dead.

This module would make a very nice example for the PIL handbook.  They should at least link to your page.

>I don't claim it's fast, just conceptually illustrative.

It seems to run about as fast as my Python function, even though I've made some efforts to optimize the performance of my Python code (100 points per function call, separating real & imaginary parts, etc.).  I guess what I should conclude is that when performance is important, don't bother trying to optimize Python.  Go straight to C, and get 10 or 100X improvement.

I'll modify my function to look more like yours, going for more clarity with only a small sacrifice in efficiency.  I can't use the nice OOP style, however, because these students have studied only functions.  OOP is an "advanced topic" covered in a later course for computer engineers, and not at all for electrical and other engineering majors. :(

At 09:17 PM 3/10/2008 -0700, Warren Sande wrote:

>For output graphics, you might want to have a look at <http://www.pygame.org/>Pygame.

I like the ability to create the image in real time directly on the screen, instead of to a file.  This should make the demo a little more interactive, and visually emphasize the speed difference between Python and C.

At 09:14 PM 3/11/2008 +1100, Steven Bird wrote:

>We're considering this book for adoption in a second year programming
>course for Engineers:
>Numerical Methods in Engineering with Python by Jaan Kiusalaas

Looks interesting, but not enough on Python for what I would like, and perhaps too much overlap with what the students learn using Matlab in other courses.  For a second-year programming course, I would chose Martelli's "Python in a Nutshell", then supplement it with lots of examples, especially rewrites of examples students have seen already in C and Java.  The improvements in clarity are dramatic.

For a first-year course, I would chose Zelle's "Python Programming".  By the way, I'm not on the faculty, just an engineer with an interest in teaching.

-- Dave

More information about the Edu-sig mailing list