T1 Boolean Logic GCSE Computer Science
T1 Boolean Logic GCSE Computer Science
Starter
• Consider a safe with two keys
• If both keys are used,
the safe will open
IF key1 AND key2 THEN
safeOpen ← True
ELSE
safeOpen ← False
• What are the only possible
values that key1 and key2
can be?
• What values must they be to open the safe?
Boolean logic
Unit 4 Computer systems
Starter
IF key1 AND key2 THEN
safeOpen ← True
ELSE
safeOpen ← False
• What are the only possible values that key1 and
key2 can be?
• Key1 and key2 can only be True or False (lock or unlock)
Binary situations
• Binary situations are common in
daily life and can refer to things
that can be in only one of two
states:
• Stop or Go
• Pass or Fail
• On or Off
• In computing terms
• A binary 1 can represent True
• A binary 0 can represent False
Boolean logic
Unit 4 Computer systems
Booleans in loops
• Booleans used in IF
statements and loops
WHILE doorOpen
turnOnLight()
ENDWHILE
Boolean logic
Unit 4 Computer systems
True or False?
Unlocking a smartphone:
• using a known fingerprint or
• using a correct PIN code?
IF fingerprint OR correctPIN THEN
unlock ← True
ELSE
unlock ← False
ENDIF
Boolean logic
Unit 4 Computer systems
Boolean functions
• AND, OR and NOT are Boolean operators
• A computer can calculate the results of A AND B,
A OR B, or NOT A
• What do these two circuit diagrams represent?
Input Output
A B
A
Input Output
B
Boolean logic
Unit 4 Computer systems
Boolean functions
• What do these two circuit diagrams represent?
AND
Input Output Both switches must be down
A B to complete the circuit
OR
A Either switch needs to be
Input Output
down to complete the circuit
B
Boolean logic
Unit 4 Computer systems
Truth tables
• A truth table shows the output from all possible
combinations of inputs from a Boolean expression
• If there are two inputs A AND B, there are four possible
combinations of TRUE and FALSE
• Both A and B must be True for the output to be True
Lift on Open
Button
correct Lift A B P
Pressed
floor Door
0 0 0 0 0 0
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1
1 1 1
Boolean logic
Unit 4 Computer systems
Boolean function – OR
• IF lane1Open OR lane2Open
• If lane one is open OR lane 2 is open then you can drive
down the road
• What is P?
lane1 lane2
P A B P
Open Open
False False ? 0 0 ?
False True ? 0 1 ?
True False ? 1 0 ?
True True ? 1 1 ?
Boolean logic
Unit 4 Computer systems
Boolean function – OR
• IF lane1Open OR lane2Open
• If lane one is open OR lane 2 is open then you can drive
down the road
• What is P?
lane1 lane2
P A B P
Open Open
More logic
Which of the following statements are True?
• (4 > 3) AND (5 > 7)
• (2 < 8) OR (8 > 10)
• NOT (5 * 7 > 30)
• ((7 DIV 3) >= 2) OR ((7 DIV 3) < 2)
• ((12 MOD 5) < 2) AND ((12 MOD 5) == 2)
• DIV gives the integer division (the result of division without any
fractional component)
• MOD gives the remainder after a division
Boolean logic
Unit 4 Computer systems
More logic
Which of the following statements are True?
• (4 > 3) AND (5 > 7) False
• (2 < 8) OR (8 > 10) True
• NOT (5 * 7 > 30) False
• ((7 DIV 3) >= 2) OR ((7 DIV 3) < 2) True
• ((12 MOD 5) < 2) AND ((12 MOD 5) == 2) False
Boolean logic
Unit 4 Computer systems
Worksheet 1
• Now complete Task 1 on Worksheet 1
Boolean logic
Unit 4 Computer systems
Example with
Logic gate Logic symbol Meaning
logic symbols
AND . A.B A AND B
OR + A+B A OR B
NOT A NOT A
XOR Ꚛ AꚚB A XOR B
Boolean logic
Unit 4 Computer systems
A B P
INPUT
A 0 0 ?
OUTPUT
P 0 1 ?
INPUT
B 1 0 ?
A B P
INPUT
A 0 0 0
OUTPUT
P 0 1 0
INPUT
B 1 0 0
A B P
INPUT
A 0 0 ?
OUTPUT
P 0 1 ?
INPUT
B 1 0 ?
Logic statement: P = A OR B 1 1 ?
Or: P = A+B
A B P
INPUT
A 0 0 0
OUTPUT
P 0 1 1
INPUT
B 1 0 1
Logic statement: P = A OR B 1 1 1
Or: P = A+B
A B P
INPUT
A 0 0 ?
OUTPUT
P 0 1 ?
INPUT
B 1 0 ?
A B P
INPUT
A 0 0 0
OUTPUT
P 0 1 1
INPUT
B 1 0 1
A P
INPUT OUTPUT 0 ?
A P
1 ?
A P
INPUT OUTPUT
0 1
A P
1 0
Worksheet 1
• Now complete Task 2 on Worksheet 1
Boolean logic
Unit 4 Computer systems
INPUT
A R OUTPUT
P
INPUT
B
A B R = A.B P=R
0 0
Logic statement:
0 1
P = A.B
1 0
1 1
Boolean logic
Unit 4 Computer systems
INPUT
A R OUTPUT
P
INPUT
B
A B R = A.B P=R
0 0 0
Logic statement:
0 1 0
P = A.B
1 0 0
1 1 1
Boolean logic
Unit 4 Computer systems
INPUT
A R OUTPUT
P
INPUT
B
A B R = A.B P=R
0 0 0 1
Logic statement:
0 1 0 1
P = A.B
1 0 0 1
1 1 1 0
Boolean logic
Unit 4 Computer systems
AND OR =
Sensor detects
Movement (S)
S N B R = S.N P = R+B
Logic statement:
P = (S.N) + B
Boolean logic
Unit 4 Computer systems
S N B R = S.N P = R+B
0 0 0
0 0 1
0 1 0 Logic statement:
0 1 1 P = (S.N) + B
1 0 0
1 0 1
1 1 0
1 1 1
Boolean logic
Unit 4 Computer systems
S N B R = S.N P = R+B
0 0 0 0
0 0 1 0
0 1 0 0 Logic statement:
0 1 1 0 P = (S.N) + B
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
Boolean logic
Unit 4 Computer systems
S N B R = S.N P = R+B
0 0 0 0 0
0 0 1 0 1
0 1 0 0 0 Logic statement:
0 1 1 0 1 P = (S.N) + B
1 0 0 0 0
1 0 1 0 1
1 1 0 1 1
1 1 1 1 1
Boolean logic
Unit 4 Computer systems
Boolean expressions
• A Boolean expression can be created for a particular
logic circuit
• What is the Boolean expression for the following circuit?
A
B P
P=?
Boolean logic
Unit 4 Computer systems
Boolean expressions
• A Boolean expression can be created for a particular
logic circuit
• What is the Boolean expression for the following circuit?
A
B P
P = A Ꚛ (B OR C)
Boolean logic
Unit 4 Computer systems
Boolean expressions
• Logic circuits can be created from a simple
Boolean expression
• What is the logic circuit for the following Boolean expression?
P = A . (B.C)
Boolean logic
Unit 4 Computer systems
Boolean expressions
• Logic circuits can be created from a simple
Boolean expression
• What is the logic circuit for the following Boolean expression?
P = A . (B.C)
A
P
C
Boolean logic
Unit 4 Computer systems
Worksheet 1
• Now complete Task 3 on Worksheet 1
Boolean logic
Unit 4 Computer systems
Plenary
• Answer the following questions with a partner:
1. Name four logic gates?
2. What are the symbols for each of these logic gates?
3. Explain what each
logic gate does
4. What is a
truth table?
Boolean logic
Unit 4 Computer systems
Plenary
1. Name four logic gates?
• AND, OR, NOT, XOR
Copyright
This unit and all the worksheets, PowerPoint presentations, teaching guides and other associated files
distributed with it are supplied to you by PG Online Limited under licence and may be used and copied by you
only in accordance with the terms of the licence. Except as expressly permitted by the licence, no part of the
materials distributed with this unit may be used, reproduced, stored in a retrieval system, or transmitted, in any
form or by any means, electronic or otherwise, without the prior written permission of PG Online Limited.
Licence agreement
This is a legal agreement between you, the end user, and PG Online Limited. This unit and all the worksheets,
PowerPoint presentations, teaching guides and other associated files distributed with it is licensed, not sold, to
you by PG Online Limited for use under the terms of the licence.
The materials distributed with this unit may be freely copied and used by members of a single institution on a
single site only. You are not permitted to share in any way any of the materials or part of the materials with any
third party, including users on another site or individuals who are members of a separate institution. You
acknowledge that the materials must remain with you, the licencing institution, and no part of the materials may
be transferred to another institution. You also agree not to procure, authorise, encourage, facilitate or enable any
third party to reproduce these materials in whole or in part without the prior permission of PG Online Limited.