Python for Education

Preface to the Revised version (May, 2020)

“Mathematics, rightly viewed, possesses not only truth, but supreme beauty — a beauty cold and austere, like that of sculpture, without appeal to any part of our weaker nature, without the gorgeous trappings of painting or music, yet sublimely pure, and capable of a stern perfection such as only the greatest art can show”, wrote Bertrand Russell about the beauty of mathematics. All of us may not reach such higher planes, probably reserved for Russels and Ramanujans, but we also have beautiful curves and nice geometrical figures with intricate symmetries, like fractals, generated by seemingly dull equations. This book attempts to explore it using a simple tool, the Python programming language.

I started using Python for the Phoenix project, started as a part of the outreach program of IUAC. Phoenix was driven in to Python by Pramode CE ( and I followed. Writing this document was triggered by some of my friends who are teaching mathematics at Calicut University. The first version was written using Lyx, a latex front-end. The present one is being done in the markdown format, that can be converted in to html or pdf formats. All the examples are now being re-written in python3.

In the first chapter, a general introduction about computers and high level programming languages is given. Basics of Python language, Python modules for array and matrix manipulation, 2D and 3D data visualization, type-setting mathematical equations using latex and numerical methods in Python are covered in the subsequent chapters. Example programs are given for every topic discussed. This document is meant for those who want to try out these examples and modify them for better understanding. Huge amount of material is already available online on the topics covered, and the references to many resources on the Internet are given for the benefit of the serious reader.

This document is distributed under the GNU Free Documentation License ( Feel free to make copies of this document and distribute through any media.

Ajith Kumar

IUAC , New Delhi

bpajith at