Answer: Logic Lights #41

The lamp is OFF. It stays dark!

The solved circuit. Wires carrying power glow yellow. The lamp is off.
Yellow wires carry power. Grey wires don’t.

Gate by gate

  1. A AND B → OFF AND OFF = OFF
  2. (A AND B) AND C → OFF AND ON = OFF

The same circuit in Python

Python has the same three gates built in: and, or and not. ON is True and OFF is False.

A = False
B = False
C = True

lamp = (A and B) and C
print("Is the lamp on?", lamp)

When you run it, it prints:

Is the lamp on? False

Try it: change one of the switches from True to False (or the other way round) and run the code again. Can you find a switch that changes the lamp?