The Python book I’m using is Teach Yourself Python in 24 Hours, by Ivan Van Laningham. It’s been around since 2000, so it’s quite a standard on the subject. There are many example programs listed in the book, both running from the command-line as well as those using the Tkinter GUI.
Chapter 23 introduces us to the Mandelbrot Set and gives a 708-line Python program to calculate the familiar colourful graphs one sees in high school mathematics.
The partial program is as follows:
from Tkinter import *
from Canvas import Line,Rectangle
from colormap import *
from tkFileDialog import *
self.xresolution = xr
self.yresolution = yr
self.cxsize = self.xresolution
self.cysize = self.yresolution
if __name__ == "__main__":
To avoid all this manual input, the author has generously published them all on his website:
Here is how the program looks on the Raspberry Pi when choosing an area to expand and then after the calculations are finished:
As you can see by the glyphs on the program window, the book’s author is a keen student of Mayan history and archeology.
“A thousand years ago, the Mayans who built a great civilization in the jungles of Central America believed that mistakes in calendrical calculations were the fault not of the scribes or the astronomers, but were the result of direct intervention by the gods. I believe this too. If you find any errors in this book, please notify gods A through Z of the Mayan pantheon. Visit them at The Mayan Gods, or report to them directly at http://www.pauahtun.org/cgi-bin/tothegods.py.”
Here are some of the other beautiful Mandelbrot pictures produced on the Raspberry Pi: