Boolean Logic Lab¶
Run the Boolean Logic Lab MicroSim Fullscreen
Edit in the p5.js Editor
About This MicroSim¶
Truth tables are usually memorized; this lab lets students build them. Two
True/False inputs feed an operator block (and, or, not) wired to a
result lamp. The lab also makes short-circuit evaluation visible: when input
A alone decides the answer (False and ..., True or ...), the B block
grays out with a "Python never looked here" badge. A truthiness panel shows
bool() verdicts for values like 0, "", [], and None, previewing
Chapter 19.
Learning objective: The student will be able to determine the result of
and, or, and not expressions and explain when Python skips evaluating
the second operand.
- Bloom's Taxonomy (2001): Understand → Apply — classify, explain, demonstrate
- Interaction pattern: input selectors with an immediate circuit-and-lamp display
How to Use¶
- Build all four rows of the
andtruth table by trying every A/B combination. Which single combination lights the lamp? - Switch to
orand find the one combination that does NOT light it. - Set A to False with
and— watch B gray out. Change B: does the result ever change? That is short-circuit evaluation. - In the bonus panel, test
bool(0),bool(""), andbool([3, 7]).
Iframe Embed Code¶
You can add this MicroSim to any web page by adding this to your HTML:
1 2 3 4 | |
Lesson Plan¶
Grade Level¶
Upper elementary and middle school (ages 10-14), Chapters 9 and 19
Duration¶
10 minutes
Prerequisites¶
- Comparison operators producing True/False (Chapter 9)
Activities¶
- Build the tables (4 min): Students record all four combinations for
andandorin a paper truth table, using the lab to verify. - Short-circuit discovery (3 min): "Set it up so that changing B does nothing. How many ways can you do it?" (Two: False-and, True-or.)
- Truthiness sort (3 min): Students predict True/False for all eight bonus values, then check.
Assessment¶
- Student completes and/or truth tables from memory
- Student can name the two short-circuit situations
- Student can classify 0, "", [], and None as falsy
References¶
- Python Documentation — Boolean Operations — including short-circuit behavior
- Python Documentation — Truth Value Testing — the falsy values list
- p5.js — the JavaScript library used to build this MicroSim