## 2.1 Logical Operators

Logical operators are used in programming. The most common operators are:

• NOT

• AND

• OR

• XOR

â€‹

A truth table displays all possible outcomes of a logical operator. The input and output values in a truth table must be a Boolean value - usually 0 or 1 but occasionally True or False.

â€‹

Because calculations can use dozens of logical operators, they are simplified in Boolean Algebra using symbols rather than words.

Â

## NOT

The NOT logical operator will produce an output which is the opposite of the input.

â€‹

It is the only logical operator that has a single input.

written as

Â

## AND

The AND logical operator will output 1 only if both inputs are also 1.

written as

Â

## OR

The OR logical operator will output 1 if either input is 1.

written as

Â

## XOR

The XOR logical operator will output 1 if the inputs are different and output 0 if the inputs are the same.

written as

## Multiple Operations

Exam questions will ask you complete truth tables that use more than one logical operator. In the example to the right, you must work out the NOT B column first and then use your answers in that column for the final column.

Read the column titles carefully to understand what is expected of you. The AND in the last column is not AND between A and B, it is AND between the NOT B column and the A column.

## Questo's Corner

Truth Tables:  Draw and complete the truth tables below.

â€‹

â€‹

â€‹

â€‹

â€‹

â€‹

â€‹