Inspired by this beautiful book, about understanding and implementing algorithms for drawing fractals, I implemented some of the algorithms from the book (Moebius transformations, depth/breadth-first search of words in transformation semigroups, ...) as a Python module. The module directly writes output as a PostScript file.
Source code and sample PostScript output.
This is a wonderful list of challenges which simultaneously train programming and teach about basic, practical cryptographic protocols, and how to break them. I currently made it up until challenge 13.
In addition, I like cryptography as a teaching tool to demonstrate the use of modular arithmetic and basic number theory.