Computational Physics with Python

When I began teaching computational physics, the first decision facing me was “which language do I use?” With the sheer number of good programming languages available, it was not an obvious choice. I wanted to teach the course with a general-purpose language, so that students could easily take advantage of the skills they gained in the course in fields outside of physics.

The language had to be readily available on all major operating systems. Finally, the language had to be free. I wanted to provide the students with a skill that they did not have to pay to use!

It was roughly a month before my first computational physics course began that I was introduced to Python by Bruce Sherwood and Ruth Chabay, and I realized immediately that this was the language I needed for my course.

It is simple and easy to learn; it’s also easy to read what another programmer has written in Python and figure out what it does. Its whitespace-specific formatting forces new programmers to write readable code. There are numeric libraries available with just what I needed for the course. It’s free and available on all major operating systems. And although it is simple enough to allow students with no prior programming experience to solve interesting problems early in the course, it’s powerful enough to be used for “serious” numeric work in physics — and it is used for just this by the astrophysics community.

Finally, Python is named for my favorite British comedy troupe. What’s not to like?