A blog of Python-related topics and code.
In his 1986 book, Surely You're Joking, Mr. Feynman! physicist Richard Feynman writes:
Just a quick script to approximate a given target image from a large number of overlapping straight lines. The algorithm is rather inefficient: each line is added to several copies of the the approximation so far, and the best one chosen (ie the one that differs least, in a root mean square sense, from the target image). The following animation is built up, using a target image adapted from
target-kitten.png (credit: Kote Puerto).
Prompted by this tweet and campaign for icebergs to be depicted in their most stable equilibrium orientation, here is a Python script modelling the dynamics of a two-dimensional iceberg which starts in an arbitrary orientation and position and relaxes under gravitational and buoyant forces to its most stable configuration. A cork floats "on its side": with its longest axis parallel to the water's surface (it doesn't bob around with its longest axis vertical), and an iceberg does the same.
As of April 2020, there were 440 operational nuclear power reactors in the world. They are listed on this Wikipedia page, which can be scraped using the code at the bottom of this post for their important details, including their locations as latitude and longitude coordinates. The result of this scraping is the CSV file
operational-nuclear-power-stations.csv, which can be analysed using pandas.