Boolean algebra and logic circuits · A level · OCR H446 1.4.3, AQA 7517 4.6.5.1, Eduqas A500QS 1.2 · about 20 min
Breaking the bar and changing the sign, NAND and NOR, and rewriting the robot's loop condition.
[1 mark]By De Morgan's law, ¬(A ∧ B) equals which expression?
[1 mark]By De Morgan's law, ¬(A ∨ B ∨ C) equals which expression?
[1 mark]What does ¬(¬A ∨ ¬B) simplify to?
[1 mark]Which Python condition means the same as not (close or hit)?
[1 mark]In AQA notation, how do A̅ · B̅ (a bar over each letter) and a single bar over the whole of A · B differ?
[1 mark]What does this program print?
result = []
for a in [0, 1]:
for b in [0, 1]:
result.append((1 - (a & b)) == ((1 - a) | (1 - b)))
print(all(result))The robot starts facing a wall. First print four check lines, one for each combination of close and hit (each 0 or 1, close in the outer loop), in exactly this form:
close=0 hit=1 original=0 rewritten=0
where original is NOT (close OR hit) and rewritten is your De Morgan version, (NOT close) AND (NOT hit), each worked out as 0 or 1 by a function of your own.
Then drive the robot towards the wall and stop in the band before it. The loop must be a while loop whose condition reads distance(), stops when the distance is under 20 cm or bumped() is true, and is written using De Morgan so that it joins its two parts with and not, with no not in front of a bracket.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
while not (distance() < 20 or bumped()):
forward(50)
wait(0.1)
stop()Plan your program here, then type it in and press Run.
if not (battery() > 20 and distance() > 30): without a not in front of the bracket.