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 is the third of the three fundamental logic gates. It takes two inputs and produces one output. The output is 1 (TRUE) when at least one of the inputs is 1. The output is 0 only when both inputs are 0.
The OR gate checks whether any of its inputs are true. For a two-input OR gate:
Think of the OR gate as a generous door policy — you can enter if you have a ticket OR if you are on the guest list OR if you have both. You are only turned away if you have neither.
| Input A | Input B | Output (A ∨ B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
The block view of the gate:
graph LR
A((A)) --> OR["OR"]
B((B)) --> OR
OR --> Q((Q = A OR B))
Notice that the output is 0 in only one row — the row where both inputs are 0. This is the opposite pattern to the AND gate.
Exam Tip: Compare AND and OR: AND has only ONE row with output 1 (both inputs must be 1). OR has only ONE row with output 0 (both inputs must be 0). This contrast is a useful way to remember the difference.
The standard symbol for a two-input OR gate has a curved left edge and a curved, pointed right edge:
+------\
A ----| \
| OR )---- Output (A ∨ B)
B ----| /
+------/
The key difference from the AND gate symbol is the curved left edge on the OR gate. The AND gate has a flat left edge.
The Boolean expression for a two-input OR gate can be written as:
The OR operation is sometimes compared to addition (but remember: in Boolean, 1 + 1 = 1, not 2 — because the maximum value is 1).
| Ordinary Maths | Boolean OR |
|---|---|
| 0 + 0 = 0 | 0 ∨ 0 = 0 |
| 0 + 1 = 1 | 0 ∨ 1 = 1 |
| 1 + 0 = 1 | 1 ∨ 0 = 1 |
| 1 + 1 = 2 | 1 ∨ 1 = 1 (not 2!) |
Imagine two light switches wired in parallel (each providing a separate path to the light). The light turns on when either switch (or both) is in the ON position. The light is only off when both switches are OFF.
+---[ Switch A ]---+
Battery ----+ +---- Light
+---[ Switch B ]---+
A fire alarm system might be connected to multiple sensors. The alarm sounds if any sensor detects smoke or heat. This is an OR condition — only one sensor needs to be triggered.
In programming, the OR operation checks whether at least one condition is true:
Python:
is_weekend = True
is_holiday = False
if is_weekend or is_holiday:
print("No school today!")
The message prints because is_weekend is True, even though is_holiday is False.
JavaScript:
if (hasTicket || isVIP) {
console.log("Welcome to the event!");
}
In Python, the keyword is or. In JavaScript, Java and C#, the symbol || is used.
| Feature | AND Gate | OR Gate |
|---|---|---|
| Output is 1 when... | Both inputs are 1 | At least one input is 1 |
| Output is 0 when... | Any input is 0 | Both inputs are 0 |
| Number of 1s in output column | 1 out of 4 rows | 3 out of 4 rows |
| Real-world analogy | Switches in series | Switches in parallel |
| Boolean symbol | ∧ or · | ∨ or + |
Like the AND gate, OR gates can have three or more inputs. The rule stays the same — the output is 1 if any input is 1.
For a three-input OR gate (A ∨ B ∨ C):
| A | B | C | Output |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
Only the first row (all 0s) produces an output of 0.
or / ||) checks that at least one condition is true.| 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.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.