Logic gates basics

Match seven gates to their rules, work out single and combined outputs, and pick the right gate for eight everyday situations. Build them afterwards in the logic gates sandbox.

Exercise20 minLower secondary +2CC BY 4.0
4 tasks · 20 min

What you will learn

  • State the rule of AND, OR, NOT, NAND, NOR, XOR and XNOR
  • Work out a gate's output from its inputs
  • Work out the output of two gates combined
  • Choose a gate for an everyday situation

A logic gate takes one or two inputs and gives one output. Each input and output is either 1 (on, true) or 0 (off, false). The gate's rule decides the output, and a truth table lists the output for every combination of inputs. Afterwards, try each gate in the logic gates sandbox.

The exercise has four tasks and takes about 20 minutes.

Need a reminder first?

A

B

AND

OR

NAND

NOR

XOR

XNOR

0

0

0

0

1

1

0

1

0

1

0

1

1

0

1

0

1

0

0

1

1

0

1

0

1

1

1

1

0

0

0

1

NOT has one input: NOT 0 = 1 and NOT 1 = 0. The "N" in NAND, NOR and XNOR means "NOT after it": every 1 of AND, OR or XOR becomes 0 and every 0 becomes 1.

Solutions with reasons

Two gates in a row

  • (1 AND 1) OR 0: the bracket gives 1, and 1 OR 0 = 1.

  • NOT (1 OR 0): 1 OR 0 = 1, and NOT 1 = 0.

  • (0 OR 1) AND (NOT 1): the first bracket is 1, the second is 0, and 1 AND 0 = 0.

  • NOT (0 AND 1): 0 AND 1 = 0, and NOT 0 = 1. This is NAND written as two steps.

  • (1 XOR 0) AND 1: 1 XOR 0 = 1, and 1 AND 1 = 1.

  • Each switch doubles the number of combinations: 2 × 2 = 4 rows for two switches, 2 × 2 × 2 = 8 for three.

Common mistakes

  • OR read as "one or the other, not both". In logic, OR is also 1 when both inputs are 1. "One or the other, not both" is XOR.

  • NAND and NOR swapped. Work out AND or OR first, then flip the answer.

  • Forgetting the brackets. In "NOT (1 OR 0)" the NOT applies to the result of the bracket, not to the 1.

For fast finishers

  1. Write XOR using only AND, OR and NOT. Test your answer for all four input pairs.

  2. Three switches A, B and C vote. Write a rule for a lamp that lights when at least two of them are on, then build it in the sandbox with the "Majority vote" challenge.

Extension solutions
  1. A XOR B = (A OR B) AND NOT (A AND B). "At least one, but not both." The sandbox challenge "XOR without XOR" checks it for you.

  2. (A AND B) OR (A AND C) OR (B AND C): any pair being on is enough. It needs three AND gates and two OR gates.

Teacher notes

How to run it. Learners work alone for about 15 minutes, then compare in pairs. With a class link (unfold "Use it with a class" below the exercise) you collect a result code from each learner and see the class average per task in Class results. It fits after the introduction to logic gates or as a check at the start of the next lesson.

Typical mistakes. OR confused with XOR (task 2, "1 XOR 1"; task 4, the alarm). NAND and NOR swapped. In task 3, learners apply NOT to the first number instead of to the bracket.

Follow-up questions.

  • Why do engineers like NAND so much? (Every other gate can be built from NAND alone, so a chip can be made from one kind of gate.)

  • How many rows does a truth table for four switches have? (16)

  • Which everyday device near you behaves like an AND gate?

Differentiation. Easier: hand out the reminder table and let learners use it for tasks 1 and 2. Harder: ask learners to draw each answer in task 4 as a circuit in the sandbox and check its truth table there.

Use it with a class
  1. 1. Copy the class link and share it with your class.
  2. 2. Learners finish the exercise and get a result code.
  3. 3. Paste the codes into Class results to see everyone at once.
Change the tasks in the builder

Reuse this material

CC BY 4.0

You may copy, adapt and share it, also commercially, as long as you credit ManyPI and link back.

"Logic gates basics" by ManyPI (https://manypi.com/edu/logic-gates-exercise), licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)