TeachyLeaf library

What are you looking for?

Search practical tutorials and browser-based tools.

Digital electronics · Logic fundamentals · Beginner

Digital logic gates: truth tables and a worked Boolean expression

Compare six common logic gates, follow a simple logic diagram, and evaluate a three-input expression for every input combination.

Who this is for: Beginners starting digital electronics. You need only be comfortable reading 0 and 1 as two distinct logic states.

What you will learn: describe AND, OR, NOT, NAND, NOR, and XOR; read their truth tables; and evaluate a compound expression in a deliberate order.

Model and limits: This lesson uses ideal Boolean logic, where each input is either 0 or 1. In a physical circuit, voltage ranges represent those states, and switching behavior depends on the logic family, supply, loading, and propagation delay. The diagram is a logic block diagram, not a circuit schematic or simulator.

Start with the three basic operations

In Boolean expressions, a variable such as A or B is a logic input. The output depends on the operation:

  • AND: the output is 1 only when both inputs are 1. Write A AND B or A · B.
  • OR: the output is 1 when at least one input is 1. Write A OR B or A + B.
  • NOT: invert one input: 0 becomes 1 and 1 becomes 0. Write NOT A or Ā.

Compare common two-input gates

NAND is the inverse of AND, NOR is the inverse of OR, and XOR is 1 when its two inputs differ. The table shows each output for all four pairs of inputs:

Two-input gate outputs
A B AND OR NOT (A AND B)
NAND
NOT (A OR B)
NOR
XOR
0000110
0101101
1001101
1111000

For a single-input NOT gate, the complete table is simply NOT 0 = 1 and NOT 1 = 0.

Read a logic block diagram

Here, A and B pass through an AND operation. Input C is inverted. Those two results then feed an OR operation to produce F:

Block diagram for F = (A AND B) OR NOT C
Logic block diagram for F equals A AND B OR NOT C Inputs A and B enter an AND block. Input C enters a NOT block. The AND and NOT outputs enter an OR block, which produces output F. A B C AND NOT OR F

Work through F = (A AND B) OR NOT C

Evaluate the parentheses first, then invert C, then OR the two results. A three-input expression has 2³ = 8 possible input combinations.

Truth table for F = (A AND B) OR NOT C
A B C A AND B NOT C F
000011
001000
010011
011000
100011
101000
110111
111101

For example, when A = 1, B = 0, and C = 1, the AND result is 0 and NOT C is 0, so F = 0. When A = 1, B = 1, and C = 1, the AND result is 1, so F = 1 even though NOT C is 0.

Practice: change the grouping

For G = (A OR B) AND NOT C, calculate G for A = 1, B = 0, C = 0 and for A = 1, B = 0, C = 1.

Show the worked answer

For both rows, A OR B = 1. When C = 0, NOT C = 1, so G = 1 AND 1 = 1. When C = 1, NOT C = 0, so G = 1 AND 0 = 0.

What the Boolean model leaves out

  • Real logic inputs are voltages interpreted as LOW or HIGH within ranges specified by a device’s logic family; they are not arbitrary exact 0 V and 1 V values.
  • Gate outputs take time to change. Propagation delay, loading, power supply, and electrical limits matter in a physical design.
  • This lesson checks logical relationships only. It does not select components, verify a circuit’s electrical compatibility, or replace a datasheet or hardware test.

Continue learning

Browse the electronics learning resources for circuit fundamentals and other lessons, or suggest a digital electronics topic.