This book review was done by Ravi Srinivasan. Ravi has been teaching children to code before any 'Hat' became popular. Though Scratch and Python are his favorite languages, he keeps in touch with most technologies. In his spare time, he plays and teaches chess. More at codewiz.in.
The book’s subtitle is: Playful Programming Activities to Make You Smarter. Did it make me smarter? Read on to find out.
Lee Vaughan is a Geology professional and he says he wrote this book for self-learners to hone their skills. The ‘impractical’ in the title can be misleading - the projects are non-trivial – they just don’t have direct commercial uses. The techniques we learn, on the other hand, are useful for a student learner or even an intermediate practitioner. While it is clearly stated that this is not an introductory book, it covers many basics as part of writing python projects. There are many diagrams, the language is conversational and the content is very interesting!
Exercises at the end of each chapter - with and without solutions are a great feature.
At the start, Lee introduces Python style – using Pylint and PEP8 – as ways to write more Pythonic code. In particular, the concept of dunder main is explained. A fun method of redirecting output to stderr in print to get a red output is shown.
The book then moves on to the topic of files and handling exceptions in the process. Another good habit introduced is having different files for distinct functionality and using them via
Problems are solved in a few interesting ways. Slices and the very cool Python list reverse idiom is shown as a way to check if a word is a palindrome, while using the splat operator to pretty print lists is something I’ll be using from now:
There is something for the intermediate programmer when the author discusses runtime optimization and the use of the
cProfile tool. The book shows how using
set instead of a
list gives a massive time improvement as we are able to run quite a complex program in less than half a minute!
The book discusses algorithms using ciphers as an example. Coding these algorithms is a great way to translate human thinking into code. Presented is an interesting way of encoding hidden meaning using steganography in Microsoft Word documents. The book uses
python-docx module to read Word files and introduces the reader to kerning (a typographic process), giving the reader insights into a new domain they may not have explored before.
The rest of the book follows the same pattern of exploring different domains via small python projects. In the process the book covers genetic algorithms, probability and randomness, generating haiku, natural language processing, finance, outer space and SETI. There is a section on Markov chain analysis where we are introduced to the AI/ML notion of training and testing datasets.
As we progress, we are introduced to object oriented python programming concepts which is then used with
tkinter to create GUIs for the projects. This is extended to an introduction to
pygame which is then used to simulate particles ejected from Io, Jupiter's moon and to simulate the Mars orbiter.
Staying on the space theme we encounter astrophotography doing image processing with
pillow and generating graphs with
Although a fair number of the projects are impractical, there is a lot to learn for beginner-intermediate programmers. They will learn how to approach problems in different domains, while getting exposed to popular third party modules like
matplotlib. You also get to learn some very useful python standard libraries like
defaultdict. The book also cements good practices like using exceptions, testing and debugging.
The writing is excellent and diagrams are used effectively. Every project is accessible and has enough explanation to motivate coding. Each major line of code is explained.
Impractical Python Projects
Playful Programming Activities to make you smarter
- Accessible projects with excellent motivation/explanation for each
- Use of many python modules that a beginner might not be exposed to
- Quite a few practice projects to do post the one detailed
- Challenge projects are really that – they can take up quite a lot of time
- A reader may not be interested in all the domains that the book touches on