Affiliate disclosure

Book titles on this page link to Amazon. As an Amazon Associate, DataField.Dev earns from qualifying purchases — at no additional cost to you.

Further Reading: Making Decisions — Conditionals and Boolean Logic

Boolean Logic and Its Origins

  • Petzold, C. (2000). Code: The Hidden Language of Computer Hardware and Software. Microsoft Press. (Tier 1) Chapters 8-11 build Boolean logic from physical switches to logic gates to the foundations of computation. An extraordinarily clear explanation of how True and False become the basis of all computing. Highly recommended.

  • Boole, G. (1854). An Investigation of the Laws of Thought. (Public domain, available free online.) (Tier 2) The original work that founded Boolean algebra. Dense and historical, but skimming the first few chapters gives you a sense of how revolutionary the idea of "logic as algebra" was. More interesting as a primary source than as a learning resource.

Python Conditionals in Depth

  • Python Documentation: "More Control Flow Tools" — if Statements, match Statements. (Tier 1) The official Python tutorial sections on conditionals and pattern matching. Concise and authoritative. Start here when you need to look something up. https://docs.python.org/3/tutorial/controlflow.html

  • Python Documentation: PEP 634 — Structural Pattern Matching: Specification. (Tier 2) The formal specification for match/case. Technical but complete. Read this when you want to understand the full power of pattern matching beyond the basics covered in this chapter — including class patterns, sequence patterns, and guard clauses. https://peps.python.org/pep-0634/

  • Python Documentation: PEP 636 — Structural Pattern Matching: Tutorial. (Tier 1) A gentler introduction to pattern matching with worked examples. More accessible than PEP 634, and covers practical use cases like processing JSON-like data structures and building simple command interpreters. https://peps.python.org/pep-0636/

Decision-Making in Software

  • Martin, R. C. (2009). Clean Code: A Handbook of Agile Software Craftsmanship. Prentice Hall. (Tier 1) Chapter 3 (Functions) and Chapter 17 (Smells and Heuristics) discuss how to keep conditional logic clean, avoid deep nesting, and structure decision-making code for readability. You'll get more from this after Chapter 6 (Functions), but the principles apply now.

  • Fowler, M. (2019). Refactoring: Improving the Design of Existing Code, 2nd Ed. Addison-Wesley. (Tier 2) Contains patterns like "Replace Nested Conditional with Guard Clauses" and "Replace Conditional with Polymorphism" — techniques for simplifying complex decision logic. Advanced, but worth bookmarking for later in the course (Chapters 14-16).

Logic and Computational Thinking

For the Curious

  • Nisan, N. & Schocken, S. (2005). The Elements of Computing Systems (a.k.a. Nand2Tetris). MIT Press. (Tier 2) Chapter 1 builds an entire computer starting from NAND gates (which implement Boolean logic in hardware). Fascinating if you want to see how the and, or, and not you use in Python relate to actual circuits. The companion course is free at nand2tetris.org.

  • Sweigart, A. Automate the Boring Stuff with Python, Chapter 2: Flow Control. (Tier 1) A practical, project-oriented take on conditionals and Boolean operators. Good as a second perspective on the same material, with different examples. https://automatetheboringstuff.com/2e/chapter2/