You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson introduces Boolean logic, a fundamental concept in computer science that underpins how all digital computers make decisions. Boolean logic is named after the mathematician George Boole (1815-1864), who developed an algebraic system for logical reasoning. In the OCR J277 specification (Section 2.5), you are expected to understand Boolean values, logic gates, truth tables, and Boolean expressions.
A Boolean value is a data type that has only two possible states:
| Value | Meaning | Binary |
|---|---|---|
| TRUE | Yes / On | 1 |
| FALSE | No / Off | 0 |
Every decision a computer makes ultimately comes down to a choice between true and false. When you press a key on a keyboard, a circuit either has current flowing (1) or it does not (0). When a program checks whether a password is correct, the answer is either true or false.
OCR Exam Tip: In the OCR J277 exam, Boolean values are always represented as 1 (true) and 0 (false). Make sure you use 1 and 0 in truth tables, not the words "true" and "false".
Computers are built from billions of tiny electronic switches called transistors. Each transistor can be in one of two states: on (1) or off (0). By combining millions of these simple on/off switches using Boolean logic, computers can perform incredibly complex calculations.
Boolean logic is used in:
if statements and while loops use Boolean expressionsIn Python and OCR pseudocode, Boolean logic appears whenever you write a condition:
# Python example
age = 16
has_id = True
if age >= 18 and has_id:
print("Entry allowed")
else:
print("Entry denied")
// OCR pseudocode
age = 16
hasID = true
if age >= 18 AND hasID then
print("Entry allowed")
else
print("Entry denied")
endif
In both examples, the condition age >= 18 evaluates to false (because 16 is not greater than or equal to 18), and has_id evaluates to true. The AND operator requires both conditions to be true, so the overall result is false and "Entry denied" is printed.
A logic gate is an electronic component that takes one or more binary inputs and produces a single binary output based on a specific Boolean rule. Logic gates are the physical implementation of Boolean logic inside a computer's circuits.
The main logic gates you need to know for OCR J277 are:
| Gate | Inputs | Rule |
|---|---|---|
| NOT | 1 | Inverts the input |
| AND | 2 | Output is 1 only if both inputs are 1 |
| OR | 2 | Output is 1 if at least one input is 1 |
| XOR | 2 | Output is 1 if inputs are different |
| NAND | 2 | Output is 0 only if both inputs are 1 |
| NOR | 2 | Output is 0 if at least one input is 1 |
Each gate has a standard symbol used in circuit diagrams and a truth table that shows every possible combination of inputs and the resulting output.
A truth table lists all possible input combinations for a logic gate and shows the output for each combination. For a gate with n inputs, there are 2^n rows in the truth table.
OCR Exam Tip: When constructing a truth table, always list the input combinations in a systematic order — start with all 0s and count up in binary: 00, 01, 10, 11. This ensures you do not miss any combinations.
| Term | Definition |
|---|---|
| Boolean value | A value that is either true (1) or false (0) |
| Logic gate | An electronic component that performs a Boolean operation |
| Truth table | A table showing all possible inputs and outputs for a logic operation |
| Boolean expression | A mathematical expression using Boolean operators (AND, OR, NOT) |
| Input | A value fed into a logic gate |
| Output | The result produced by a logic gate |