It's been 11 years, since Doing Math With Python was published. The world of software learning has changed drastically. I hope you are still continuing to learn using books, writing programs and the educators among you, i hope you are doing the same! We must persist.
The book has also ended up being part of the Anthropic copyright settlement. I think it's just a sign of the times and I have become part of the history it appears!
Alright, so, I am going to be doing a bit of a refresh as needed for the various code in the book and solutions to ensure that they are all working with currently latest versions of the Python programming language and the third party packages that's used for the code: sympy, matplotlib and matplotlib_venn.
This will take a while, so here's the software versions i will be working with:
- Python 3.14
- sympy 1.14.0
- matplotlib 3.11.0
- matplotlib_venn 1.1.2
This post is in progress
Chapter 2
Programming challenges
- How does the temperature vary during the day?
One solution I suggested created the two lists with the data manually filled in from the google search results.
The second solution, (file name: nyc_forecast_owm.py) I proposed uses the pyowm package to download the data from open weather map. A reader wrote to me recently that it doesn't work any more.
I took a look at the proposed solution and realized that the API itself has changed, which means the library pyowm had also changed significantly. Not unexpected, since it's been 11 years.
So, this is the new proposed solution to use the real data:
- No need to use a third party package
- Download the CSV file from a new source
- Read the CSV file data to create the graph
I suppose my original intention for asking the reader to use a third party package might have been an attempt to stretch the enterprising reader. However, I don't agree with that intention any more as demonstrating how to use a third party data provider isn't in the scope of the book. So, I am taking it out.
I have created a new web application dedicated for this exercise so that you can download the data in CSV data format - something you learn in the book in Chapter 3 (next chapter).
Reading the CSV file requires the reader to refer to Chapter 3
Here's my proposed updated solution.
First download the data by:
- Visit: https://doingmathwithpython.ai.studio/ and sign up (you don't provide email)
- Next sign in using the username and password
- By default New York is selected and default is also selected to 1 day
- On the top right you can change the temperature units
- Click on Download CSV data
A file will be downloaded which will have the data in the following format:
"Local Date & Time","Temperature" "2026-11-03 19:00","63.1" "2026-11-03 22:00","60.3" "2026-11-04 01:00","58.5" "2026-11-04 04:00","57.6" "2026-11-04 07:00","56.5" "2026-11-04 10:00","63.7" "2026-11-04 13:00","68.7" "2026-11-04 16:00","67.6"
Rename the file to weather_New_York_1d_3h.csv and place in the same directory as the program.
Here's the plan of what we will need to do:
- Ignore the first line (CSV header row)
- Read each row, creating one list for the time of the day and a second list for the temperature
- Create our graph
You can find the updated solution here.