The NAND (= "not and") logic gate takes two bits as an input. Its output follows the rule: "if the bits aren't both $1$ (i.e., if at least one of bit is $0$,) output $1$; otherwise, output $0$." You can implement it in your code as follows: given the Boolean variables $x$ and $y$, the symbol: $!(x \&\& y)$ or $(xy)'$ means "$x$ nand $y$". Below is the NAND gate diagram and truth table.
Bonus question: How can we build a NAND gate if we know how to build NOT, AND, OR, and XOR gates?
NAND Gate diagram. Miriam Briskman, CC BY-NC 4.0.
| Input | Output | |
|---|---|---|
| $x$ | $y$ | $(xy)'$ |
| $0$ | $0$ | $1$ |
| $0$ | $1$ | $1$ |
| $1$ | $0$ | $1$ |
| $1$ | $1$ | $0$ |