New Book Review: "Python Programming for Beginners"

New book review for Python Programming for Beginners: A Kid's Guide to Coding Fundamentals, by Patricia Foster, Rockridge Press, 2020:

Python_programming_for_beginners

Copy provided by Amazon.

In her one-page "How to Use this Book" introduction, Foster states that "this book will teach you the basics of Python programming", and "it's going to teach you how to think like a coder!" The material is broken down into the following ten chapters, followed by half a dozen pages comprising debugging tips, a glossary, and a list of suggested web resources: (1) "Welcome to Programming!", (2) "Python: The Basics", (3) "Variables", (4) "Data Types", (5) "Data Structures", (6) "Conditionals", (7) "Loops", (8) "Functions", (9) "Turtle Module", and (10) "Game On: Putting it All Together". 

The author's presentation is organized well, introducing topics which build upon each other along the way, and the illustrations at the beginning of each chapter are colorful, catering to pre-teen children interested in programming fundamentals. Unfortunately, there are also many issues along the way. While I initially made an effort to ignore these issues, I started taking notes after finding myself losing track. Children working through this book, and those guiding them, will likely not notice these issues unless acquainted with programming themselves, in which case they also will likely not be in the target market for this book.

Foster comments at the outset in chapter 1 that "a program is a bunch of code designed to solve a human problem". While she follows this statement with a decent conceptual explanation of programs, which have goals carried out by a sequence of step-by-step instructions, as a longtime developer and architect I know that many programs are definitely not about human problems: many programs simply do not have end user humans in mind. The author also tackles some tricky words (e.g. for "algorithm" and "compile") at much too early a stage, and it would have likely been better to leave these out of her presentation.

Discussing integrated development environments (IDEs) in chapter 2 is also arguably covered much too soon, because this topic doesn't teach the basics of Python programming, not does it teach how to think like a coder, the two primary goals laid out in the introduction. For the pre-teen beginner, it makes sense to initially use what is provided out-of-the-box when downloading and installing Python for the first time, rather than getting too sidetracked on available options. I'm in agreement with the author's two primary goals. Understand the basic programming process first, and then use your experiences to help guide you.

During the author's explanation of variables in chapter 3, the f-string is introduced. Essentially, f-strings are a way to format strings, and the author demonstrates how to use these to keep track of variable values by printing them during program execution. Interestingly, however, the "How to Install Python" section in chapter 2 specifically comments about all the different Python releases currently made available, going so far as to state that the specific release used by the reader to execute the code presented in this book doesn't matter as long as you "make sure the first number after the word  'Python' is a 3". Not so: the f-string was not introduced until Python 3.6, so if a prior 3.x release of Python is used, this functionality simply won't work.

In chapter 3, during the presentation on the order in which Python math operations are carried out, the author mentions that the BEDMAS acronym can help figure this out, that "B" stands for "brackets", and that brackets are evaluated first. But the example used during this discussion is "n = ( 3 + 2 ) * 4". So where are the brackets in this example? In revisiting the text which led to this discussion, I saw that in a sidebar 15 pages earlier a distinction was made between "round brackets" and "square brackets". In my many years of professional experience, I've never heard anyone refer to parentheses (i.e. "parens") as "round brackets"!

The "Alien Socks" example just three pages later that uses the equation "num_socks = num_martians * martian_legs / 2" doesn't make use of any parentheses. In this case, it doesn't technically matter how the math operations are grouped, but it's advised for new programmers to get in the habit of making code more readable, in this case making use of the equation "num_socks = num_martians * ( martians_legs / 2 )" because the emphasis is on pairs of legs in the story problem. Perhaps not coincidentally, the final calculated value in this story problem is an integer, but new programmers should understand the difference between floating point and decimal numeric data types, and the subsequent two-page discussion on numbers in chapter 4 doesn't discuss this topic.

While I didn't come across any book examples that are wrong, per se, some are likely to be awkward or confusing. For example, in chapter 6, during the discussion of "if-elif-else" statements, three variables are presented: "is_winter", "is_fall", and "is_summer". While I appreciate the variable naming convention that makes use of an "is" prefix to indicate a boolean data type, why isn't "is_spring" defined? One can argue that the program example assumes possibility of the Spring season, and indeed the explanation for this example mentions all four seasons, and that the season of Spring is assumed if not Summer, Fall, or Winter, but what's this? The branching logic only explicitly checks for Winter and Fall, and if not Winter or Fall, Summer is assumed. A perfect example of a bug for chapter 2.

Another confusing example is "Find the Buried Treasure" in chapter 7. The story problem leading up to the code that is presented states that buried treasure can be found in a beach that a crew of pirates has separated into 100 sections assigned the numbers "1" to "100". However, the code permits values of "0" to "100" as guesses. Why? Neither the story problem nor the code provides an explanation. While I've made some guesses as to why a value of "0" can be guessed, it would have been helpful for the author to either explain why this is the case, or simply remove the ability to choose "0" as a guess.

This book periodically makes use of built-in Python functions, but only haphazardly makes use of these in the code that is presented. I found it surprising, for example, that in the "Anagram Checker" example of chapter 8 neither the functions "upper()" or "lower()" are used. The code is simple, comparing two string variable values to each other to determine whether both are comprised of the same letters. At the end of this example, the author states that "to a computer, uppercase and lowercase matter a lot", so "keep this in mind when comparing anagrams!" A perfect time to introduce these two functions!

While chapters 9 and 10 introduce some important concepts, and are likely intended to provide some fun, I personally think these chapters should either have been left out or reworked to provide more substance. In reading through the book to this point, I noticed that objects had not yet been introduced, and unfortunately, the beginning of chapter 9 provides full disclosure: "this book won't show you how to define your own objects". Likewise, the "Spaceships and Aliens" game in chapter 10 might be entertaining, but players choose 4 digits (i.e. single integers), but these are stored as strings that aren't evaluated by the code to ensure that integer values are chosen. Another perfect example of a bug for chapter 2.

This book is the third introductory programming book that I've reviewed in recent months, joining "Tanmay Teaches Julia for Beginners: A Springboard to Machine Learning for All Ages", and "Coding Concepts for Kids". Of these three, I view "Coding Concepts for Kids" as the best, but it doesn't teach a programming language, instead opting to teach how to think like a coder. Interestingly, this is the second stated goal of "Python Programming for Beginners", but it is very simplistic, targeted at younger readers. The book reviewed here is a good attempt, but in my opinion doesn't meet either of its two goals.

Subscribe to Erik on Software

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe