Here are the main types of logical gates:
1. **AND Gate**
Operation: Outputs `1` (True) only if all its inputs are `1`. Otherwise, it outputs `0`.
- Truth Table:
| Input A | Input B | Output |
|---------|---------|--------|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
2. OR Gate
-Operation: Outputs `1` if at least one of its inputs is `1`. It outputs `0` only if all inputs are `0`.
- Truth Table:
| Input A | Input B | Output |
|---------|---------|--------|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
3. NOT Gate (Inverter)
- Operation: Takes a single input and inverts it. If the input is `1`, the output is `0`, and vice versa.
- Truth Table:
| Input | Output |
|-------|--------|
| 0 | 1 |
| 1 | 0 |
4. NAND Gate
- Operation: Outputs the opposite of an AND gate. It outputs `0` only if all inputs are `1`; otherwise, it outputs `1`.
- Truth Table:
| Input A | Input B | Output |
|---------|---------|--------|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
5. NOR Gate
- Operation: Outputs the opposite of an OR gate. It outputs `1` only if all inputs are `0`; otherwise, it outputs `0`.
- Truth Table:
| Input A | Input B | Output |
|---------|---------|--------|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
6. XOR Gate (Exclusive OR)
- Operation: Outputs `1` if exactly one of its inputs is `1`, but not both. It outputs `0` if both inputs are the same.
- Truth Table:
| Input A | Input B | Output |
|---------|---------|--------|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
7. XNOR Gate (Exclusive NOR)
- Operation: Outputs `1` if both inputs are the same (either both `0` or both `1`). Otherwise, it outputs `0`.
- Truth Table:
| Input A | Input B | Output |
|---------|---------|--------|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
These gates are typically used in combination to create more complex circuits that perform functions like arithmetic, decision-making, and data storage in computers.