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 10 ("Logic and Switches") and 11 ("Gates (Not Bill)") build Boolean logic from physical switches up to logic gates, and the chapters that follow turn those gates into a working computer. An extraordinarily clear explanation of how
TrueandFalsebecome the basis of all computing. Highly recommended. A revised 2nd edition (2022) covers the same ground in Chapters 6-8 ("Logic with Switches," "Telegraphs and Relays," "Relays and Gates"). -
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" —
ifStatements,matchStatements. (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) The book's 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. The 2nd edition's examples are in JavaScript, but the ideas carry straight over to Python. Advanced, but worth bookmarking for later in the course (Chapters 14-16). Short summaries of each refactoring are in the online catalog. https://refactoring.com/catalog/
Logic and Computational Thinking
- Evans, D. (2011). Introduction to Computing: Explorations in Language, Logic, and Machines. (Free online.) (Tier 1) Chapter 3 (Programming) covers decision-making expressions, and Chapter 6 (Machines) shows how logic is mechanized in hardware. The examples use Scheme (with Python appearing later in the book), so expect different syntax. Good for students who want a deeper understanding of why Boolean logic is the foundation of computation. https://computingbook.org/
For the Curious
-
Nisan, N. & Schocken, S. (2021). The Elements of Computing Systems: Building a Modern Computer from First Principles, 2nd Ed. (a.k.a. Nand2Tetris). MIT Press. (Tier 2) Chapter 1 (Boolean Logic) starts from a single NAND gate and builds
And,Or, andNotfrom it; the rest of the book keeps going until you have an entire working computer. Fascinating if you want to see how theand,or, andnotyou use in Python relate to actual circuits. The companion course is free at nand2tetris.org. -
Sweigart, A. Automate the Boring Stuff with Python, 3rd Ed. (No Starch Press), Chapter 2: "if-else and Flow Control." (Tier 1) A practical, project-oriented take on conditionals and Boolean operators, free to read online. Good as a second perspective on the same material, with different examples. (It doesn't cover
match/case.) https://automatetheboringstuff.com/3e/chapter2.html