Think Python 2ed.

by Allen B. Downey

Think Python is an introduction to Python programming for beginners. It starts with basic concepts of programming, and is carefully designed to define all terms when they are first used and to develop each new concept in a logical progression. Larger pieces, like recursion and object-oriented programming are divided into a sequence of smaller steps and introduced over the course of several chapters.

Description from LibreTexts.

Publisher
Olin College
Subjects
Engineering, Computer Science
Licence
CC BY-NC 3.0, as LibreTexts states it. Non-commercial use only.
Who can read
Tweens profiles and older, judged from its title and subjects

Contents

LibreTexts writes equations in TeX, and here they show as TeX; the PDF has them typeset.

  1. Front Matter
  2. TitlePage
  3. InfoPage
  4. Table of Contents
  5. Licensing
  6. 0: Preface
  7. 1.1: The strange history of this book
  8. 1.2: Acknowledgments
  9. 1.3: Contributor List
  10. 1: The way of the program
  11. 1.1: What is a program?
  12. 1.2: Running Python
  13. 1.3: The first program
  14. 1.4: Arithmetic operators
  15. 1.5: Values and types
  16. 1.6: Formal and natural languages
  17. 1.7: Debugging
  18. 1.8: Glossary
  19. 1.9: Exercises
  20. 2: Variables, expressions and statements
  21. 2.1: Assignment statements
  22. 2.2: Variable names
  23. 2.3: Expressions and statements
  24. 2.4: Script mode
  25. 2.5: Order of operations
  26. 2.6: String operations
  27. 2.7: Comments
  28. 2.8: Debugging
  29. 2.9: Glossary
  30. 2.10: Exercises
  31. 3: Functions
  32. 3.1: Function calls
  33. 3.2: Math functions
  34. 3.3: Composition
  35. 3.4: Adding new functions
  36. 3.5: Definitions and uses
  37. 3.6: Flow of execution
  38. 3.7: Parameters and arguments
  39. 3.8: Variables and parameters are local
  40. 3.9: Stack diagrams
  41. 3.10: Fruitful functions and void functions
  42. 3.11: Why functions?
  43. 3.12: Debugging
  44. 3.13: Glossary
  45. 3.14: Exercises
  46. 4: Case study - interface design
  47. 4.1: The turtle module
  48. 4.2: Simple repetition
  49. 4.3: Exercises
  50. 4.4: Encapsulation
  51. 4.5: Generalization
  52. 4.6: Interface design
  53. 4.7: Refactoring
  54. 4.8: A development plan
  55. 4.9: docstring
  56. 4.10: Debugging
  57. 4.11: Glossary
  58. 4.12: Exercises
  59. 5: Conditionals and recursion
  60. 5.1: Floor division and modulus
  61. 5.2: Boolean expressions
  62. 5.3: Logical operators
  63. 5.4: Conditional execution
  64. 5.5: Alternative execution
  65. 5.6: Chained conditionals
  66. 5.7: Nested conditionals
  67. 5.8: Recursion
  68. 5.9: Stack diagrams for recursive functions
  69. 5.10: Infinite recursion
  70. 5.11: Keyboard input
  71. 5.12: Debugging
  72. 5.13: Glossary
  73. 5.14: Exercises
  74. 6: Fruitful functions
  75. 6.1: Return values
  76. 6.2: Incremental development
  77. 6.3: Composition
  78. 6.4: Boolean functions
  79. 6.5: More recursion
  80. 6.6: Leap of faith
  81. 6.7: One more example
  82. 6.8: Checking types
  83. 6.9: Debugging
  84. 6.10: Glossary
  85. 6.11: Exercises
  86. 7: Iteration
  87. 7.1: Reassignment
  88. 7.2: Updating variables
  89. 7.3: The while statement
  90. 7.4: break
  91. 7.5: Square roots
  92. 7.6: Algorithms
  93. 7.7: Debugging
  94. 7.8: Glossary
  95. 7.9: Exercises
  96. 8: Strings
  97. 8.1: A string is a sequence
  98. 8.2: len
  99. 8.3: Traversal with a for loop
  100. 8.4: String slices
  101. 8.5: Strings are immutable
  102. 8.6: Searching
  103. 8.7: Looping and counting
  104. 8.8: String methods
  105. 8.9: The in operator
  106. 8.10: String comparison
  107. 8.11: Debugging
  108. 8.12: Glossary
  109. 8.13: Exercises
  110. 9: Case study - word play
  111. 9.1: Reading word lists
  112. 9.2: Exercises
  113. 9.3: Search
  114. 9.4: Looping with indices
  115. 9.5: Debugging
  116. 9.6: Glossary
  117. 9.7: Exercises
  118. 10: Lists
  119. 10.1: A list is a sequence
  120. 10.2: Lists are mutable
  121. 10.3: Traversing a list
  122. 10.4: List operations
  123. 10.5: List slices
  124. 10.6: List methods
  125. 10.7: Map, filter and reduce
  126. 10.8: Deleting elements
  127. 10.9: Lists and strings
  128. 10.10: Objects and values
  129. 10.11: Aliasing
  130. 10.12: List arguments
  131. 10.13: Debugging
  132. 10.14: Glossary
  133. 10.15: Exercises
  134. 11: Dictionaries
  135. 11.1: A dictionary is a mapping
  136. 11.2: Dictionary as a collection of counters
  137. 11.3: Looping and dictionaries
  138. 11.4: Reverse lookup
  139. 11.5: Dictionaries and lists
  140. 11.6: Memos
  141. 11.7: Global variables
  142. 11.8: Debugging
  143. 11.9: Glossary
  144. 11.10: Exercises
  145. 12: Tuples
  146. 12.1: Tuples are immutable
  147. 12.2: Tuple assignment
  148. 12.3: Tuples as return values
  149. 12.4: Variable-length argument tuples
  150. 12.5: Lists and tuples
  151. 12.6: Dictionaries and tuples
  152. 12.7: Sequences of sequences
  153. 12.8: Debugging
  154. 12.9: Glossary
  155. 12.10: Exercises
  156. 13: Case study - data structure selection
  157. 13.1: Word frequency analysis
  158. 13.2: Random numbers
  159. 13.3: Word histogram
  160. 13.4: Most common words
  161. 13.5: Optional parameters
  162. 13.6: Dictionary subtraction
  163. 13.7: Random words
  164. 13.8: Markov analysis
  165. 13.9: Data structures
  166. 13.10: Debugging
  167. 13.11: Glossary
  168. 13.12: Exercises
  169. 14: Files
  170. 14.1: Persistence
  171. 14.2: Reading and writing
  172. 14.3: Format operator
  173. 14.4: Filenames and paths
  174. 14.5: Catching exceptions
  175. 14.6: Databases
  176. 14.7: Pickling
  177. 14.8: Pipes
  178. 14.9: Writing modules
  179. 14.10: Debugging
  180. 14.11: Glossary
  181. 14.12: Exercises
  182. 15: Classes and objects
  183. 15.1: Programmer-defined types
  184. 15.2: Attributes
  185. 15.3: Rectangles
  186. 15.4: Instances as return values
  187. 15.5: Objects are mutable
  188. 15.6: Copying
  189. 15.7: Debugging
  190. 15.8: Glossary
  191. 15.9: Exercises
  192. 16: Classes and functions
  193. 16.1: Time
  194. 16.2: Pure functions
  195. 16.3: Modifiers
  196. 16.4: Prototyping versus planning
  197. 16.5: Debugging
  198. 16.6: Glossary
  199. 16.7: Exercises
  200. 17: Classes and methods
  201. 17.1: Object-oriented features
  202. 17.2: Printing objects
  203. 17.3: Another example
  204. 17.4: A more complicated example
  205. 17.5: The init method
  206. 17.6: The __str__ method
  207. 17.7: Operator overloading
  208. 17.8: Type-based dispatch
  209. 17.9: Polymorphism
  210. 17.10: Debugging
  211. 17.11: Interface and implementation
  212. 17.12: Glossary
  213. 17.13: Exercises
  214. 18: Inheritance
  215. 18.1: Card objects
  216. 18.2: Class attributes
  217. 18.3: Comparing cards
  218. 18.4: Decks
  219. 18.5: Printing the deck
  220. 18.6: Add, remove, shuffle and sort
  221. 18.7: Inheritance
  222. 18.8: Class diagrams
  223. 18.9: Debugging
  224. 18.10: Data encapsulation
  225. 18.11: Glossary
  226. 18.12: Exercises
  227. 19: The Goodies
  228. 19.1: Conditional expressions
  229. 19.2: List comprehensions
  230. 19.3: Generator expressions
  231. 19.4: any and all
  232. 19.5: Sets
  233. 19.6: Counters
  234. 19.7: defaultdict
  235. 19.8: Named tuples
  236. 19.9: Gathering keyword args
  237. 19.10: Glossary
  238. 19.11: Exercises
  239. 20: Appendix A - Debugging
  240. 20.1: Syntax errors
  241. 20.2: Runtime errors
  242. 20.3: Semantic errors
  243. 21: Appendix B - Analysis of Algorithms
  244. 21.1: Order of growth
  245. 21.2: Analysis of basic Python operations
  246. 21.3: Analysis of search algorithms
  247. 21.4: Hashtables
  248. 21.5: Glossary
  249. Back Matter
  250. Index
  251. Glossary
  252. Detailed Licensing