Logic gates practice
The fastest way to learn logic gates is to answer lots of small questions and see the reason each time. Pick a kind of question below: the output of one gate, which gate a truth table belongs to, the output of a small circuit, or a whole truth table to fill in. The questions never run out, and every circuit answer opens as a live circuit, checked by the simulator, that you can take into the lab.
The gates at a glance
| Gate | A=0 B=0 | 0 1 | 1 0 | 1 1 | The rule |
|---|---|---|---|---|---|
| AND | 0 | 0 | 0 | 1 | 1 only when both are 1 |
| OR | 0 | 1 | 1 | 1 | 1 when at least one is 1 |
| NAND | 1 | 1 | 1 | 0 | 0 only when both are 1 |
| NOR | 1 | 0 | 0 | 0 | 1 only when both are 0 |
| XOR | 0 | 1 | 1 | 0 | 1 when they differ |
| XNOR | 1 | 0 | 0 | 1 | 1 when they are equal |
NOT has one input and outputs its opposite: 0 becomes 1 and 1 becomes 0. Every gate has its own live page with the truth table: AND, OR, NOT, NAND, NOR, XOR and XNOR.
How to trace a circuit
Work from the inputs to the output, one gate at a time. Take Y = (A NAND B) OR C with
A = 1, B = 1 and C = 0. The inner gate comes first: 1 NAND 1 = 0. Then the outer gate uses that value:
0 OR 0 = 0, so Y = 0. For a truth table, do the same for all eight rows, and add a column for each inner gate
so you never have to hold more than one step in your head. The truth
table generator builds the whole table for any expression you type, and the
logic circuit generator draws its gates.
Common mistakes
Mixing up OR and XOR: OR is 1 when both inputs are 1, XOR is 0. Forgetting the bubble: NAND, NOR and XNOR are the opposite of AND, OR and XOR on every row. And evaluating the outer gate before the inner one: an inner gate's output is an input to the next gate, so it has to be known first. When a rule will not stick, build the gate yourself: the AND and NAND lessons show how each one is made from transistors, and combining gates covers circuits like the ones above.
Frequently asked
How can I practice logic gates?
Answer many small questions with instant feedback: the output of a gate for given inputs, which gate a truth table belongs to, the output of a small circuit, and whole truth tables. This page generates all four kinds without end and explains every answer.
What are the 7 basic logic gates?
AND, OR, NOT, NAND, NOR, XOR and XNOR. NOT has one input; the others here have two. NAND, NOR and XNOR are AND, OR and XOR followed by a NOT.
How do you find the output of a logic circuit?
Work from the inputs toward the output. Write the value at each inner gate's output first, then use those values as the inputs of the next gate, until you reach Y.
How do you make a truth table for a logic circuit?
List every input combination (8 rows for three inputs, counting in binary from 000 to 111), add a column for each inner gate, fill those columns row by row, then combine them into the output column.
What is an easy way to remember the logic gates?
AND needs all inputs 1, OR needs at least one, XOR needs them to differ. A bubble (the N in NAND, NOR, XNOR) flips the answer, so NAND is 0 only when both inputs are 1.
Ready for more than practice? In the free course you build these gates from CMOS transistors, then adders, memory and an 8-bit CPU. Read about every gate in logic gates explained, or simplify expressions with the Boolean algebra calculator. For number practice, try the binary game.
Open the lab →