How to Think Like a Computer Scientist: Learning with Python
Allen Downey, Franklin W. Olin College of Engineering
Jeff Elkner, Yorktown High School
Chris Meyers, Lane Community College
Copyright Year: 2008
Publisher: Green Tea Press
Conditions of Use
This book is fairly comprehensive, touching on all the major topics of introductory Computer Science and the specifics of the Python language. Each chapter introduces relevant CS terms and provides a helpful glossary at the end of the chapter.... read more
This book is fairly comprehensive, touching on all the major topics of introductory Computer Science and the specifics of the Python language. Each chapter introduces relevant CS terms and provides a helpful glossary at the end of the chapter. However, some sections offered only a cursory glance and are missing important topics (e.g., order of operations is not fully explained for Boolean operations, list operations are light and do not include valuable methods such as .append). But overall, the book is sufficient as a companion to a course, but not particularly as a reference or independent way of learning.
While reading, I did not notice any errors or biases in the content. The code examples provided look correct and the actual source code for all examples used in the book are provided, so they can be easily tested for accuracy.
The content is excellent in this regard. The concepts and terminology used are fairly universal to Computer Science and not Python-specific. In addition, the source files for both the manuscript and code examples are provided for easier collaboration and remixing. One critique I have is that the LaTeX source for the book is contained entirely in one file, making it difficult to isolate specific sections for reuse.
This book is written in a conversational tone, without being informal, which is hard to find in a textbook. The language used is accessible, technical terms are clearly introduced and used only when needed to explain concepts. The use of code examples help to illustrate the points made in the text and show readers what is happening, instead of just telling them.
The text properly uses the terms it introduces (which are highlighted in bold upon first occurrence, and also re-defined in each glossary section). These terms are continually used in the following chapters. Readers should have no issue searching through the index and glossaries either if they need to review specific terms.
The chapters in the book are designed to be self-contained. For the most part, this held true: most chapters contained all the knowledge you would need to understand a given topic. However, this comes with a major drawback. Oftentimes, a topic would be interspersed throughout chapters (e.g., functions are presented in multiple sections). This makes it difficult if you are teaching one topic and need readings that focus on that topic alone.
This was, in my opinion, the largest weakness of the book. Oftentimes, sections within a chapter would feel out-of-place. For example, the section on recursion is combined with the chapter on conditionals; although conditionals are needed to write recursive functions, the section does not fit the rest of the chapter and is not standalone enough to be considered modular. Keyboard input is also introduced in that same chapter on conditionals.
This is a common theme I noticed throughout the book. When topics in a chapter require knowledge of other topics, the book decides to introduce the prerequisite knowledge in an ad-hoc fashion. Sometimes this is even unnecessary, and just confusing (e.g., the modulo operator is introduced with conditionals, as opposed to with the other arithmetic operators, because an example uses it to show alternative execution). The concepts of local variables is introduced with iteration, and random numbers are introduced alongside tuples, which does not make logical sense.
The text reads clearly and is properly formatted to ease with reading. Figures and examples are clearly presented (although more graphical figures could help illustrate concepts such as flow of execution, functions, and string indices).
I did not encounter any grammatical errors in my review of the book.
The text does not contain any offensive language or examples. As a programming book, the text is surprisingly accessible and should be readable regardless of background.
After completing my review, I found an updated version called "Think Python". However, upon a cursory readthrough, many of my points (specifically on modularity and organization) still hold.
I find that the book is quite comprehensive including both the Python language and also important data structures. The Python-specific glossaries are very helpful at the end of each chapter. Also, the Appendixes are essential for those who are new... read more
I find that the book is quite comprehensive including both the Python language and also important data structures. The Python-specific glossaries are very helpful at the end of each chapter. Also, the Appendixes are essential for those who are new to Python.
This book sound very accurate to me, partly due to the fact that a lot of people have contributed to make it error-free.
The book did an excellent job for introducing basic Python concepts. However Python 3 has been released which is incompatible with the 2.4 on which this version of the book is based. I think the authors should be able to update it to a new version with no problem.
Overall this book is very easy to follow for me.
Both terms, and concepts are consistent through the whole book. Each chapter nicely flows from basic to advanced.
The whole book is divided into 20 chapters plus three appendices, which are self-contained and easily accessible for quick reference. The whole book flows naturally from chapter to chapter, which will make it easier for the beginner to progress.
As my comments in modularity, the book is well organized. The book ends up with some important advanced data structures such as Stacks, Queue and Trees, which are important for Computer Engineering students.
There are no found interface issues. The book consists quite a lot of example snippets code for hands-on experience. As mentioned in Relevance, these snippets code are designed for Python 2.4, which might not be compatible for Python 3.
I have found no grammatical errors.
It is about programming language. No cultural issues.
I will use this book for the required reference book for my classes including Computer Network and Computer Security. In Network class, Python has been used for network socket programming. In Security classes, Python has been adopted as main script language for small tasks such as attack payload construction. This book will help my electrical engineering students who do not have a strong programming experience as computer engineering students do, but are interested to take my Computer Network class and Computer Security class.
The text begins with by associating problem-solving with programming and then moves ahead into a detailed description of Python. From there, the text moves logically ahead to variables, functions, operators, etc. I found the end of chapter... read more
The text begins with by associating problem-solving with programming and then moves ahead into a detailed description of Python. From there, the text moves logically ahead to variables, functions, operators, etc.
I found the end of chapter glossary very useful (and preferred over one large glossary) and the index to be comprehensive.
The text's content appears to be accurate and unbiased. While I did not run each program in the text as of this writing, all of the programs I did run performed as expected with one exception, the program listed on p. 8. In Python 3.6, the code to run the program requires a slight modification (the addition of opening and closing parens) to:
print ("Hello, World!")
This was true in all cases, but is a trivial matter.
The text's content is excellent and offers extensive coverage for an introductory python programming course. While trivial aspects of the language will always be subject to evolution, the concepts covered should be long-lived.
Educators and students alike can decide the depth to which they want to learn python by completing the content through chapter 11, or decide to include more depth in classes, inheritance, sets, and queues, which admittedly, are more complex topics.
The explanations given should be well-received by beginning students and even complex topics, such as the concept of a variable, usually a source of great discomfort to students, are well-described and handled.
The text is written in a flowing, easy to read manner and clearly explains terms as they are introduced. For example, the coverage of recursion in chapter 4 is excellent. In my experience, most students struggle with this concept. However, the simple and easy to understand examples given help the student understand the necessity of asking a running function to again call (run) itself.
The text's framework seems to match the introduction of concepts and flow of competing introductory Python courses with what seems to be a natural course separation after chapter 11, where afterwards, classes are introduced, along with more complex topics.
Chapter topics are broken down into discrete, logical sections with easy to understand and execute snippets of code. The flow of the material seems natural, so that students can progress through the text in the order in which topics are presented.
The topics in the text are presented in a logical, clear fashion, as I've mentioned in many of my prior review comments.
I also appreciate the appendices. For example, Appendices B and C direct the student to additional study materials for further study.
This text seems quite easy to navigate with no issues related to distorted images (there aren't very many images - mostly code snippets).
The grammar used in the text seems appropriate for a college freshman course. I did not locate any grammatical errors.
I only located one instance of the use of 'his or her' and no references to he/him or her/she. Most references were to the "user" rather than an actual person. While this is not an offense, I recommend using actual user names that can then infer cultural inclusiveness.
I like the flow of the material and code examples. If a student wanted to use this text, she could easily install and use Python 2. However, the slight changes between versions 2 and 3 might frustrate the student as they subsequently move to the newer version. On the other hand, this is a great opportunity to learn troubleshooting and experience what programmers in the "real world" experience way too often as versions and systems change regularly.
This text covers all fundamental elements of funtional programming using python. Chapters are well structured and concise enough to be approached in an orderly fashion. read more
This text covers all fundamental elements of funtional programming using python.
Chapters are well structured and concise enough to be approached in an orderly fashion.
Some challenge exists in maintaining all the examples and exercises in line with current state of the discipline. This is most notable in sections referencing the Internet which is understandable. Other than that, the text is up to date with the python functionality well described and implemented in the examples. A flag noting the recency of updates might be helpful here to better key users into possible areas of concern.
Python programming is a constantly evolving and dynamic domain. The authors are making great effors to keep the text updated with ongoing versions of the software. The text has already forked into versions for python 2 and python 3 further challenging the authors.
Appropriate terminology is used throughout the text. Concepts are introducted, described, and demonstrated in clear prose.
Comments are used extensively within code segments to provide context and support comprehension and retention.
The prose is highly consistent, utilizing appropriate terms and concepts to train early programmers. Subsections on good programming practice are well distributed throughout the text, providing a regular reinforcement of behavior and structure. Chapters are kept relatively the same size, so each occupies the same timeframe within the semester. No overly long or short chapters are present making for ease of use within the weekly course calendar.
Highly modular, the chapters lend themselves to hopping around as necessary. Some chapters rely on previous work and a travelers key would be a useful addendum, identifying any clear content dependencies.
Exercises are well integrated into the chapter and provide ample opportunity to practice the concepts presented.
I appreciate the outline and approach taken by the authors in covering the fundamental concepts of Python programming language.
I have had difficulty in the past with the Turtle based chapters, specifically in getting the turtle modules to correctly load and execute. This presents a problem in following the text by chapter.
I would prefer a forking architecture with the graphics chapters in a seperate thread which can be used or ignored as necessary.
While this is nearly impossible to accomplish in a printed text I can appreciate the more linear nature of the text. But as this is now primarily available as an online resource it may be worth revisiting the strategy for presenting the material.
The authors have done a superb job to present all images in straightforward and consistent size, font, color and frame. This is particularly true with examples which can be easily cut and paste into an editor and executed to demonstrate the concepts being covered.
Syntax and grammar are consistently high and well structured. I have found no glaring grammatical errors. As programming computer syntax is a language unto itself, the authors do a good job of keeping the two separate in the textual descriptions of the concepts and implementation of python code.
The text relies on two primary cultural touchstones throughout. The first, Monty Python, is understandable in the context that the language name was chosen to honor this British comedy troop.. The second, Alice in Wonderland, is used to explore string and file manipulation. Neither is particularly relevant to the exercise and could easily be replaced by other sources of text. There are no insensitive or offensive uses of language or cultural reference to my understanding.
I have used this text as the primary course material for three years and am very satisfied with it.
The book provides a great introduction to Python programming. It reads at a level of a beginning programmer, though even novices should enjoy it. The basic syntax and semantics of Python are covered, including functions and objects. Some of the... read more
The book provides a great introduction to Python programming. It reads at a level of a beginning programmer, though even novices should enjoy it. The basic syntax and semantics of Python are covered, including functions and objects. Some of the more advanced features are missing, and readers are encouraged to continue on to other books. Every chapter provides a glossary of new technical terms at the end. There is a comprehensive index at the end of the book.
All content was accurate. I spotted no errors and I did not feel there was any bias in the material.
The book is up to date with Python 2 syntax. Since it focuses on beginner Python, most of the concepts should not really change over time. Newer, more advanced concepts can easily be added in the future as additional chapters.
The book is very easy to read. Technical terms are introduced only when necessary and typically given via an example. Each chapter contains a glossary of new terms at the end for review.
The book is very consistently organized and presented. Most chapters read similarly to previous chapters. Terminology from prior chapters is consistently applied in later chapters.
Overall the book is modular. There are 20 chapters each around 11 pages in length. Generally, a concept is fully covered within a single chapter. The exception is the functions, which for some reason are not entirely covered within a single chapter but actually in several chapters. Overall however it should be easy to reorganize/split the reading in a course.
The organization and flow of the book is quite nice. It starts with simple concepts and slowly builds up more complex concepts. There were only a few places where I was wondering 'why is this here?' for example, when introducing the modulus operator. It felt very out of place, even though I kept reading and realized it was necessary for the chapter's examples. I also felt like the last several chapters seemed strangely out of place for the book as a whole. Almost like the authors decided to tack on a quick intro to data structures at the end.
I read the PDF version and felt the interface was about what you would expect. I was disappointed that there were not hyperlinks in the PDF to easily jump from TOC or Index directly to the page. A quick glance through the HTML version indicates it is quite usable. The HTML version seems to syntax color the code while the PDF does not for some reason.
I did not spot any issues with spelling or grammar in the book. The book has clearly had some careful proof reading.
The examples from the book should not be offensive to any particular culture.
This book is designed for beginning programmers, but it still useful for readers with prior programming experience. The book starts out with a well-written discussion of algorithms, machine language, and other helpful foundational material for new... read more
This book is designed for beginning programmers, but it still useful for readers with prior programming experience. The book starts out with a well-written discussion of algorithms, machine language, and other helpful foundational material for new programmers. The following chapters introduce the elements of the Python language in a thorough and comprehensive fashion. There is certainly much more that could be said about Python, but the scope seems just right for an introductory text.
I did not note any errors or issues with accuracy.
This text has been around for several years (current edition = 2008) and is a popular and widely known textbook on the Python language. The authors should be able to update it without a problem as new versions of Python are released.
I teach an introductory programming course myself, so I have an eye for concepts that can easily trip up new programmers. I think the greatest strength of this text is the simple, readable prose and the logical manner in which the material is presented. In courses such as math, chemistry, and physics, students are trained to learn a new concept and then apply that concept to example problems and homework exercises by following the pattern in the examples. While this is still true to a certain degree in programming courses, programming is more open-ended and there is often a large number of ways one can use the syntax and structure of the language to accomplish a given task. This open-ended nature can be a major stumbling block for some new programmers, who feel more secure with a "cook book" approach to problem solving. As the title of the book indicates, the text is written in a way that teaching the students to think algorithmically, thus empowering them to harness the creative aspect of programming.
The text maintains a consistent tone throughout. The terminology is consistent and new terms and concepts are introduced in a logical manner.
The text is divided into 20 chapters, each of which covers a specific topic. However, one has to be careful when not reading the text sequentially. For example, functions are introduced in chapter 3, but it is not a complete coverage. Functions are further explained in the following two chapters: 4 and 5. It seems the authors have organized the book in this fashion in order to keep each chapter short and focused, which is a worthy goal. But an instructor would need to be careful about assigning portions of the book to cover specific topics.
Excellent organization. Simple foundational topics are covered first and the chapters progress to more advanced topics at the end.
The PDF version is nicely formatted. The HTML version is simple and easy to navigate.
The book provides a good overview of Python syntax and basic functions, while also examining more complicated and potentially confusing concepts (e.g., abstract data types). Python-specific glossaries are provided at the end of each chapter, and... read more
The book provides a good overview of Python syntax and basic functions, while also examining more complicated and potentially confusing concepts (e.g., abstract data types). Python-specific glossaries are provided at the end of each chapter, and the ideas build from simple to complex. The book is good for both beginner and intermediate developers.
I worked through about a third of the code, and found no errors. I focused primarily on the concepts and less on the computation, and was pleased to see that - although the book can be useful as a tutorial - it also stands alone as a conceptual problem solving book, which reaffirms the title phrase, “how to think like a computer scientist.”
The emphasis on general programming concepts, and the exploration of computer science as a means of designing methods, functions, and algorithms to solve linear or iterative/recursive problems makes the utility of the book long lasting. Additionally, the focus on simple and fundamental core concepts (such as syntax and format), increases the usefulness of the book for beginner and intermediate level programmers.
Generally speaking, the authors carefully and deliberately explain the use of Python for solving specific computational problems. The later chapters become a bit abstract, but this is probably the nature of the concepts, and not so much a shortcoming of the explanations. Iterative readings, as well as continued programmatic familiarity, will help the reader understand more clearly.
From a formatting perspective (i.e., bold, italics), the book does a good job of communicating types of Python language. At the end of each chapter, the glossary of newly introduced concepts helps cement the ideas further.
The themes and structure of the book are consistent from chapter to chapter, and relatively easy to follow. The concepts build consistently upon each other, from very simple to complex and abstract. Most importantly, the example problems are topically consistent, and are touched upon in multiple chapters (i.e., programming a card game).
The structure of the book lends itself to modular development, and even repeatedly reminds the reader to break processes down into smaller, more manageable chunks. The book also repeatedly suggests the benefit of generalizing snippets of code into tools that can be recycled into multiple workflows.
The flow of the book is good, incrementally proceeding from very basic examples of statements and functions to more complicated examples of classes and objects. The typological formatting of the book is explicitly designed to communicate an at-times non-intuitive Python vocabulary. The structure of the chapters becomes suitably familiar, and often iterates through multiple examples of achieving similar or identical results with varied syntax and structure.
The book is not designed to be a step-by-step tutorial, but instead balances applicable code examples with a narrative about the advantages and simplicity of programming in Python. In between sections, the reader is invited (in italics) to be creative and fix or enhance code without explicit or obvious guidance. The book will reward the casual reader and dedicated coder alike.
No grammatical errors of note.
The primary cultural relevance of this book is to make computer science more user-friendly, familiar, and attainable by providing tangible examples of programming as, essentially, stepwise problem solving. Additionally, coding is not portrayed as being particularly easy or difficult; good code is attainable, but it takes thought (to plan ahead of time) and patience (to fix afterwards).
I really enjoyed the combination of a broad overview and detailed examples of “how to think like a computer scientist,” and I look forward to reading again and recommending to my students as a good intro to programming generally and Python specifically.
The book covers the basics of programming in the Python language in a very readable fashion. The materials are organized reasonably well. The new concepts are always introduced to have a direct comparison to previous Chapters. The new terminology... read more
The book covers the basics of programming in the Python language in a very readable fashion. The materials are organized reasonably well. The new concepts are always introduced to have a direct comparison to previous Chapters. The new terminology is revisited in the end of each Chapter. The PDF file lacks links, which makes the reading slightly inconvenient. Each Chapter includes one or two questions for the students to think and code. More examples and Problems are definitely very welcome and helpful. I understand that this is a short book, but some important concepts, such as List Comprehensions, are not discussed. Overall, the book serves very well as introductory materials for the students to grab fundamental programming concepts using Python, and does this job very effectively.
I only spotted one minor error throughout the whole book. On pg 48, the “type string” should be “type str”.
The book's topics are very basic and so always relevant for Python Programming. Many people are concerned about the transition to Python 3 that has significant difference to Python 2 in terms of data types and many other aspects. That should be a completely new book to cover Python 3. I think the current book did an excellent job for introducing those basic Python concepts and styles that will definitely last in future versions.
The explanations and examples are extremely clear. For example, whenever a new type or new concept is introduced, it is directly compared or differentiated from previous chapters. Furthermore, the technical terminology is clearly defined throughout the text and in the end of each chapter.
The overall style of chapters is very consistent.
The text is divided up into 20 chapters and three appendices. All of them are relatively short with ~10 page each. The overall grouping of materials is excellent. Chapters are generally built upon previous chapters and it is better to read through in sequence.
The content is well structured. All the Chapters are very short and concise for specific data types or concepts, such as String, List, Tuples, Dictionary, Function, and Class. The flow is very well from simple to more complex, and new terminology are introduced in the beginning and revisited in the end in such a way that reader can also grab the difference to relevant ones in previous Chapters and that follows.
The main critic of this book is lack of links, which makes the navigation a little inconvenient. That would be helpful if the PDF can be made crossed-linked. Also, organizing the code in blocks instead of spreading out all over the place would make people test the code easier.
I was not aware of any grammatical errors in the book. Apparently, the book has been proof read by many authors and probably many readers as well.
For this matter, I did not find anything worthy of mentioning. No material presented in this book is cultural sensitive or offensive to any group of people.
I was very motivated to review this book upon request because my research group uses Python quite extensively as an interface language to electronic structure modeling. The book serves very well as introductory materials to students who do not have much programming background. Some of my students and myself did not have strong interests to understand or apply some of the concepts covered in the book (e.g., Queues, Tree). But overall I found it to be very readable, and I plan to use it as the required reading material for new group members and for a modeling course I am developing.
Table of Contents
- 1 The way of the program
- 2 Variables, expressions and statements
- 3 Functions
- 4 Conditionals and recursion
- 5 Fruitful functions
- 6 Iteration
- 7 Strings
- 8 Lists
- 9 Tuples
- 10 Dictionaries
- 11 Files and exceptions
- 12 Classes and objects
- 13 Classes and functions
- 14 Classes and methods
- 15 Sets of objects
- 16 Inheritance
- 17 Linked lists
- 18 Stacks
- 19 Queues
- 20 Trees
- Appendix A: Debugging
- Appendix B: Creating a new data type
- Appendix C: Recommendations for further reading Index
About the Book
How to Think Like a Computer Scientist: Learning with Python is an introduction to programming using Python.
About the Contributors
Allen Downey is an American computer scientist, Professor of Computer Science at the Franklin W. Olin College of Engineering and writer of free textbooks. Downey received in 1989 his BS and in 1990 his MA, both in Civil Engineering from the Massachusetts Institute of Technology, and his PhD in Computer Science from the University of California at Berkeley in 1997. He started his career as Research Fellow in the San Diego Supercomputer Center in 1995. In 1997 he became Assistant Professor of Computer Science at Colby College, and in 2000 at Wellesley College. He was Research Fellow at Boston University in 2002 and Professor of Computer Science at the Franklin W. Olin College of Engineering since 2003. In 2009-2010 he was also Visiting Scientist at Google Inc.
Jeffrey Elkner is a high school math and computer science teacher at Yorktown High School in Arlington, Virginia.
Chris Meyers is a professional programmer who teaches a beginning Python class at Lane Community College in Eugene, Oregon.