Answer: Logic Lights #122

The lamp is ON. It lights up!

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

Gate by gate

  1. NOT B → NOT OFF = ON
  2. A AND NOT B → ON AND ON = ON
  3. C OR D → OFF OR ON = ON
  4. (A AND NOT B) AND (C OR D) → ON AND ON = ON

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 = True
B = False
C = False
D = True

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

When you run it, it prints:

Is the lamp on? True

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?