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 OR gate takes two inputs and produces an output of 1 when at least one input is 1. It is one of the three fundamental logic gates (along with AND and NOT) and is essential knowledge for OCR J277 Section 2.5.
The OR gate implements logical disjunction. The output is 1 (true) when input A or input B (or both) is 1. The output is 0 only when both inputs are 0.
In Boolean algebra, OR is written as:
OCR Exam Tip: Be careful not to confuse the Boolean OR symbol (+) with arithmetic addition. In Boolean algebra, 1 + 1 = 1 (not 2). The + symbol means OR, not "add".
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
The output is 0 in only one row — when both inputs are 0. In all other cases, the output is 1.
The standard OR gate symbol has a curved back (input side) and a pointed front (output side), resembling an arrowhead or shield shape:
A ----\ /---- Q
| OR |
B ----/ \
The two inputs enter from the left, and the single output exits from the right. There is no bubble at the output.
In Python:
# Using the or keyword
is_weekend = True
is_holiday = False
if is_weekend or is_holiday:
print("No school today!")
else:
print("Time for school")
In OCR pseudocode:
isWeekend = true
isHoliday = false
if isWeekend OR isHoliday then
print("No school today!")
else
print("Time for school")
endif
Since isWeekend is true, the OR condition evaluates to true — you only need at least one condition to be true.
Imagine two light switches connected in parallel controlling a single light bulb:
| Switch A | Switch B | Light |
|---|---|---|
| Off | Off | Off |
| Off | On | On |
| On | Off | On |
| On | On | On |
The light turns on if either switch (or both) is on. This is an OR operation.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.