Recreational mathematics with Python

Why Python?

Python is a programming language developed by Guido van Rossum in 1991. With Python, you can quickly write computer programs and run them on a variety of different platforms. It is now one of the best known and most popular programming languages ​​and it is easy to learn. The reason why Python was chosen as the programming language here is that it comes very close to the experience of home computer programming.

An Amstrad CPC 464 home computer from 1984. (Image: Bill Bertram; CC BY-SA 2.5)

Home computers were a class of microcomputers that emerged in the 1970's. They were relatively inexpensive and therefore became popular in the 1980's. The computers of the early days were usually 8 bit machines (i.e. Amstrad CPC, Commodore C64, ZX Spectrum, Atari XT, Apple II). In some cases they were later superseded by 16 bit models (i.e. Commodore Amiga, Atari ST) but the golden days of home computing were the days of the 8 bit machines. Those were the times when you manually typed in the source code found in Magazines and marvelled at a few colored (or green) pixels on your computer screen. It was common to develop a good set of programming skills just by playing with the machine. You learned the basics of programming. Even if you could buy programs on diskette or cassette, you still had to know the commands to load them into the main and execute it.

Home computers were practically standardized, all models in a series had the same graphics, the same speed and had the same operating system. If you wanted an operating system update, you had to replace a chip on the board. This standardization had an advantage as it was easy to write programs that ran on all computers of a manufacturer or at least a certain series. The programming hurdle was much lower than today. Graphics could be drawn on the screen with just a few lines of source code. Many programmers learned with these devices. What many modern programming languages ​​lack is this simplicity. This is different with Python, it allows you to concentrate on the essential function of a program without having to think about hundreds of lines of source code for the initialization of the graphics subsystem. This makes it much easier to get started with programming.

Examples

Programming with the right tools doesn't have to be complicated. To demonstrate this, I have put together a number of programming examples. These examples have one thing in common: Their source code fits on a single page. Each of the examples is discussed and described in detail.

Game of Life

John Conway's "Game of Life" is a cellular automaton. It shows how complex patterns and shapes can be created from a simulation with just a few rules.

The Chaos Game

The chaos game is a simple algorithm for generating fractals. It was invented by Michael Barnsley. The version implemented here creates a multitide of different patterns with an iterative random algorithm.