You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
The NAND and NOR gates are the inverted versions of AND and OR respectively. They are formed by combining AND or OR with NOT. These gates are covered in OCR J277 Section 2.5 and are particularly important because NAND and NOR gates are considered universal gates — any logic circuit can be built using only NAND gates or only NOR gates.
NAND stands for NOT AND. It performs an AND operation and then inverts the result. The NAND gate outputs 0 only when both inputs are 1 — the exact opposite of AND.
| A | B | A AND B | A NAND B |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
Notice that the NAND output is the exact inverse of the AND output. Every 0 becomes 1 and every 1 becomes 0.
OCR Exam Tip: To find the output of a NAND gate, first work out what AND would give, then invert it. This two-step approach avoids mistakes.
The NAND symbol is the AND symbol with a bubble (small circle) at the output:
flowchart LR
A((A)) --> NAND["AND gate with output bubble (NAND)"]
B((B)) --> NAND
NAND --> Q((Q))
The bubble represents the NOT (inversion) applied to the AND output.
NOR stands for NOT OR. It performs an OR operation and then inverts the result. The NOR gate outputs 1 only when both inputs are 0 — the exact opposite of OR.
| A | B | A OR B | A NOR B |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 |
The NOR output is the exact inverse of the OR output.
The NOR symbol is the OR symbol with a bubble at the output:
flowchart LR
A((A)) --> NOR["OR gate with output bubble (NOR)"]
B((B)) --> NOR
NOR --> Q((Q))
| Gate | Output is 1 when... | Number of 1s in output | Symbol feature |
|---|---|---|---|
| NOT | Input is 0 | 1 out of 2 | Triangle + bubble |
| AND | Both inputs are 1 | 1 out of 4 | Flat-back D shape |
| OR | At least one input is 1 | 3 out of 4 | Curved shield shape |
| XOR | Inputs are different | 2 out of 4 | OR + extra curve |
| NAND | NOT both inputs are 1 | 3 out of 4 | AND + bubble |
| NOR | Both inputs are 0 | 1 out of 4 | OR + bubble |
OCR Exam Tip: NAND and NOR are the inverses of AND and OR. Count the number of 1s in the output column: AND has 1, NAND has 3; OR has 3, NOR has 1. This can help you identify a gate from its truth table.
A universal gate is a gate that can be used to build any other logic gate. Both NAND and NOR are universal gates.
For example, using only NAND gates:
This is important in chip manufacturing — factories can produce circuits using only one type of gate, which is simpler and cheaper.
While Python does not have dedicated nand or nor keywords, you can express them:
# NAND
a = True
b = True
result = not (a and b) # False
print(result)
# NOR
a = False
b = False
result = not (a or b) # True
print(result)
In OCR pseudocode:
// NAND
result = NOT (a AND b)
// NOR
result = NOT (a OR b)
OCR GCSE Computer Science (J277) only examines AND, OR, and NOT. NAND and NOR are covered at A Level (OCR H446 / J417). This lesson is included for completeness, but in your Paper 2 exam answers you must rewrite any NAND or NOR behaviour using only AND, OR, and NOT.
Fortunately the conversion is simple — NAND and NOR are defined by inversion:
A NAND B = NOT (A AND B)A NOR B = NOT (A OR B)So whenever you see a NAND-style or NOR-style truth table in a J277 exam, express the answer as a NOT applied to an AND or OR expression.
Suppose a question gives you this truth table:
| A | B | Q |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
This is the NAND pattern. At J277 level, the expected answer is:
Q = NOT (A AND B)
Or, using the J277 algebra notation: Q = (A . B)̄.
Do not write A NAND B in a J277 answer — it is not a recognised operator on the specification.
Truth table:
| A | B | Q |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
This is NOR. The J277 expression is:
Q = NOT (A OR B)
Or Q = (A + B)̄ in algebraic notation.
OCR Exam Tip: If the truth table has one 1 and three 0s and the 1 is in the top row (all inputs 0), the expression is
NOT (A OR B). If the truth table has three 1s and one 0 and the 0 is in the bottom row (all inputs 1), the expression isNOT (A AND B).
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.