How to Think Like a Computer Scientist: Interactive Edition
This interactive book is a product of the Runestone Interactive Project at Luther College, led by Brad Miller and David Ranum. There have been many contributors to the project. Our thanks especially to the following:
- This book is based on the Original work by: Jeffrey Elkner, Allen B. Downey, and Chris Meyers
 - Activecode based on Skulpt
 - Codelens based on Online Python Tutor
 - Many contributions from the CSLearning4U research group at Georgia Tech.
 - ACM-SIGCSE for the special projects grant that funded our student Isaac Dontje Lindell for the summer of 2013.
 - NSF
 
The Runestone Interactive tools are open source and we encourage you to contact us, or grab a copy from GitHub if you would like to use them to write your own resources.
Table of ContentsΒΆ
- 1. General Introduction
- 1.1. The Way of the Program
 - 1.2. Algorithms
 - 1.3. The Python Programming Language
 - 1.4. Executing Python in this Book
 - 1.5. More About Programs
 - 1.6. What is Debugging?
 - 1.7. Syntax errors
 - 1.8. Runtime Errors
 - 1.9. Semantic Errors
 - 1.10. Experimental Debugging
 - 1.11. Formal and Natural Languages
 - 1.12. A Typical First Program
 - 1.13. Comments
 - 1.14. Glossary
 
 - 2. Simple Python Data
- 2.1. Variables, Expressions and Statements
 - 2.2. Values and Data Types
 - 2.3. Type conversion functions
 - 2.4. Variables
 - 2.5. Variable Names and Keywords
 - 2.6. Statements and Expressions
 - 2.7. Operators and Operands
 - 2.8. Input
 - 2.9. Order of Operations
 - 2.10. Reassignment
 - 2.11. Updating Variables
 - 2.12. Glossary
 - 2.13. Exercises
 
 - 3. Debugging Interlude 1
 - 4. Python Turtle Graphics
- 4.1. Hello Little Turtles!
 - 4.2. Our First Turtle Program
 - 4.3. Instances — A Herd of Turtles
 - 4.4. The 
forLoop - 4.5. Flow of Execution of the for Loop
 - 4.6. Iteration Simplifies our Turtle Program
 - 4.7. The range Function
 - 4.8. A Few More turtle Methods and Observations
 - 4.9. Summary of Turtle Methods
 - 4.10. Glossary
 - 4.11. Exercises
 
 - 5. Python Modules
 - 6. Functions
- 6.1. Functions
 - 6.2. Functions that Return Values
 - 6.3. Variables and Parameters are Local
 - 6.4. The Accumulator Pattern
 - 6.5. Functions can Call Other Functions
 - 6.6. Flow of Execution Summary
 - 6.7. Using a Main Function
 - 6.8. Program Development
 - 6.9. Composition
 - 6.10. A Turtle Bar Chart
 - 6.11. Glossary
 - 6.12. Exercises
 
 - 7. Selection
 - 8. More About Iteration
- 8.1. Iteration Revisited
 - 8.2. The 
forloop revisited - 8.3. The 
whileStatement - 8.4. Randomly Walking Turtles
 - 8.5. The 3n + 1 Sequence
 - 8.6. Newton’s Method
 - 8.7. Algorithms Revisited
 - 8.8. Simple Tables
 - 8.9. 2-Dimensional Iteration: Image Processing
 - 8.10. Image Processing on Your Own
 - 8.11. Glossary
 - 8.12. Exercises
 
 - 9. Strings
- 9.1. Strings Revisited
 - 9.2. A Collection Data Type
 - 9.3. Operations on Strings
 - 9.4. Index Operator: Working with the Characters of a String
 - 9.5. String Methods
 - 9.6. Length
 - 9.7. The Slice Operator
 - 9.8. String Comparison
 - 9.9. Strings are Immutable
 - 9.10. Traversal and the 
forLoop: By Item - 9.11. Traversal and the 
forLoop: By Index - 9.12. Traversal and the 
whileLoop - 9.13. The 
inandnot inoperators - 9.14. The Accumulator Pattern with Strings
 - 9.15. Turtles and Strings and L-Systems
 - 9.16. Looping and Counting
 - 9.17. A 
findfunction - 9.18. Optional parameters
 - 9.19. Character classification
 - 9.20. Summary
 - 9.21. Glossary
 - 9.22. Exercises
 
 - 10. Lists
- 10.1. Lists
 - 10.2. List Values
 - 10.3. List Length
 - 10.4. Accessing Elements
 - 10.5. List Membership
 - 10.6. Concatenation and Repetition
 - 10.7. List Slices
 - 10.8. Lists are Mutable
 - 10.9. List Deletion
 - 10.10. Objects and References
 - 10.11. Aliasing
 - 10.12. Cloning Lists
 - 10.13. Repetition and References
 - 10.14. List Methods
 - 10.15. The Return of L-Systems
 - 10.16. Append versus Concatenate
 - 10.17. Lists and 
forloops - 10.18. Using Lists as Parameters
 - 10.19. Pure Functions
 - 10.20. Which is Better?
 - 10.21. Functions that Produce Lists
 - 10.22. List Comprehensions
 - 10.23. Nested Lists
 - 10.24. Strings and Lists
 - 10.25. 
listType Conversion Function - 10.26. Tuples and Mutability
 - 10.27. Tuple Assignment
 - 10.28. Tuples as Return Values
 - 10.29. Glossary
 - 10.30. Exercises
 
 - 11. Files
 - 12. Dictionaries
 - 13. Recursion
 - 14. Classes and Objects - the Basics
- 14.1. Object-oriented programming
 - 14.2. A change of perspective
 - 14.3. Objects Revisited
 - 14.4. User Defined Classes
 - 14.5. Improving our Constructor
 - 14.6. Adding Other Methods to our Class
 - 14.7. Objects as Arguments and Parameters
 - 14.8. Converting an Object to a String
 - 14.9. Instances as Return Values
 - 14.10. Glossary
 - 14.11. Exercises
 
 - 15. Classes and Objects - Digging a Little Deeper