What Are Logic Gates?
A logic gate is an electronic circuit that takes one or more binary inputs (each either 0 or 1) and produces a single binary output (either 0 or 1), based on a specific logical rule. Logic gates are the fundamental building blocks of all digital circuits โ from simple calculators to the processors inside your smartphone.
Every arithmetic operation your computer performs, every comparison it makes, and every decision in every program you run is ultimately carried out by combinations of millions of logic gates switching billions of times per second.
The behaviour of a logic gate is completely described by its truth table โ a table that lists every possible combination of inputs and the output that results from each combination.
Remember: In logic gates, 1 means TRUE (or HIGH voltage) and 0 means FALSE (or LOW voltage). These correspond directly to the binary digits you learned in the binary number system.
The Six Fundamental Logic Gates
You need to know six logic gates for KCSE Computer Studies. Each gate has a name, a symbol, a Boolean expression and a truth table.
AND Gate
Output is 1 only when ALL inputs are 1
Boolean expression: Y = A ยท B (or A AND B)
Real-world analogy: A door that opens only when BOTH keys are inserted simultaneously.
| A | B | Y = A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR Gate
Output is 1 when AT LEAST ONE input is 1
Boolean expression: Y = A + B (or A OR B)
Real-world analogy: A light that turns on if EITHER switch A or switch B (or both) is flipped.
| A | B | Y = A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
NOT Gate (Inverter)
Output is the OPPOSITE of the input
Boolean expression: Y = ฤ (or NOT A)
Real-world analogy: An alarm that sounds when a sensor does NOT detect someone โ it inverts the signal.
| A | Y = NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
Note: The NOT gate has only ONE input, unlike the others.
NAND Gate
NOT AND โ opposite of the AND gate output
Boolean expression: Y = โพ(AยทB) (NOT of A AND B)
Key fact: NAND is called a "universal gate" โ you can build any other logic gate using only NAND gates.
| A | B | Y = NAND |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NOR Gate
NOT OR โ opposite of the OR gate output
Boolean expression: Y = โพ(A+B) (NOT of A OR B)
Key fact: NOR is also a universal gate โ like NAND, you can build any circuit using only NOR gates.
| A | B | Y = NOR |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
XOR Gate (Exclusive OR)
Output is 1 when inputs are DIFFERENT
Boolean expression: Y = A โ B
Real-world analogy: A staircase light controlled by two switches โ the light is on only when the two switches are in different positions.
| A | B | Y = XOR |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
How to Read a Logic Gate Question
KCSE questions typically give you a logic circuit diagram with gates connected together, provide specific input values, and ask you to determine the final output. Here is a systematic approach:
- Identify each gate in the circuit and its type (AND, OR, NOT, etc.).
- Start from the inputs on the left and work right toward the output.
- Calculate the output of each gate using its truth table.
- Feed that output as the input to the next gate.
- Continue until you reach the final output.
Worked Example 1 โ Combined Gates
A circuit has inputs A=1, B=0, C=1. Gate 1 is AND (inputs A, B). Gate 2 is OR (inputs: output of Gate 1, and C). Find the output.
Step 1: Gate 1 (AND): A=1, B=0 โ 1 AND 0 = 0
Step 2: Gate 2 (OR): output of Gate 1 = 0, C = 1 โ 0 OR 1 = 1
Final output: 1
Worked Example 2 โ Using De Morgan's Laws
Simplify: NOT(A AND B). According to De Morgan's first law, this equals NOT A OR NOT B.
If A=1, B=0: NOT(1 AND 0) = NOT(0) = 1
Verify with De Morgan: NOT A OR NOT B = NOT(1) OR NOT(0) = 0 OR 1 = 1 โ
De Morgan's Laws
De Morgan's laws are two essential rules for simplifying Boolean expressions involving NOT, AND and OR:
- First Law: NOT(A AND B) = NOT A OR NOT B. In other words, NAND = NOT A OR NOT B.
- Second Law: NOT(A OR B) = NOT A AND NOT B. In other words, NOR = NOT A AND NOT B.
These laws are extremely useful for simplifying complex logic circuits and converting between gate types. They appear frequently in KCSE Paper 1 questions.
KCSE Tips for Logic Gates
- Memorise the key outputs for each gate: AND outputs 1 only when all inputs are 1. OR outputs 0 only when all inputs are 0. NOT flips the input. NAND and NOR are the complements of AND and OR respectively. XOR outputs 1 only when inputs differ.
- Draw truth tables carefully: Always list ALL possible input combinations in order (00, 01, 10, 11 for two inputs) so you do not miss any row.
- Universal gates: Know that NAND and NOR are universal โ you can be asked to draw a NOT gate using only NAND gates, for example.
- Boolean notation: AยทB means AND; A+B means OR; ฤ means NOT A. Be comfortable with all three notations.
โ Practice Logic Gates
Test your knowledge with interactive truth table questions and SVG gate diagrams.
Play Logic Gates Game โSummary
There are six fundamental logic gates: AND (output 1 only if all inputs are 1), OR (output 1 if any input is 1), NOT (inverts a single input), NAND (inverse of AND), NOR (inverse of OR), and XOR (output 1 only when inputs differ). Each gate is completely described by its truth table. NAND and NOR are universal gates. De Morgan's laws link NAND to NOT-OR and NOR to NOT-AND. Logic gates are the building blocks of all digital circuits and all computer processors.