Preface xi
1. Programming as a Way of Thinking 1
2. Variables and Statements 15
3. Functions 27
4. Functions and Interfaces 39
5. Conditionals and Recursion 55
6. Return Values 73
7. Iteration and Search 91
8. Strings and Regular Expressions 105
9. Lists 121
10. Dictionaries 137
11. Tuples 153
12. Text Analysis and Generation 171
13. Files and Databases 191
14. Classes and Functions 209
15. Classes and Methods 223
16. Classes and Objects 233
17. Inheritance 249
18. Python Extras 269
19. Final Thoughts 289
Index 293
Python is an excellent way to get started in programming, and this clear, concise guide walks you through Python a step at a time—beginning with basic programming concepts before moving on to functions, data structures, and object-oriented design. This revised third edition reflects the growing role of large language models (LLMs) in programming and includes exercises on effective LLM prompts, testing code, and debugging skills.
With this popular hands-on guide at your side, you'll get:
A grounding in the syntax and semantics of the Python language
A clear definition of each programming concept, with emphasis on clear vocabulary
How to work with variables, statements, functions, and data structures in a logical progression
Techniques for reading and writing files and databases
A solid understanding of objects, methods, and object-oriented programming
Debugging strategies for syntax, runtime, and semantic errors
An introduction to recursion, interface design, data structures, and basic algorithms
How to use LLMs—including effective prompts, testing code, and debugging
And more