Logic and computer systems · GCSE · OCR J277 2.4.1, AQA 8525 3.4.2, Edexcel 1CP2 1.3.1 · about 15 min
AND, OR and NOT, their symbols and truth tables, and a robot decision as a circuit.
[1 mark]When does an AND gate output 1?
[1 mark]When does an OR gate output 0?
[1 mark]How many rows does a truth table for 3 inputs have?
[1 mark]A is 1 and B is 1. What is A AND (NOT B)?
[1 mark]What does this program print?
def AND(a, b): return 1 if a and b else 0 def NOT(a): return 1 - a print(AND(1, NOT(0)), NOT(AND(1, 1)))
[1 mark]Which gate has only one input?
Write AND(a, b), OR(a, b) and NOT(a) as functions that take and return 0 or 1. Print the truth table for A AND (NOT B), one row per line in the form A=0 B=1 Q=0, trying every combination with loops.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
def AND(a, b):
return 0Plan your program here, then type it in and press Run.
NOT (A OR B). Which gate does it match the opposite of?bumped().