
Logic Gates
Input 1 | Input 2 | Output |
---|---|---|
off | off | on |
off | on | off |
on | off | on |
on | on | off |
#False means off
#True means on
top_switch = False
bottom_switch = False
first_gate = top_switch and bottom_switch
second_gate = not(first_gate or bottom_switch)
if second_gate:
print("light on")
else:
print("light off")
Input 1 | Input 2 | Output |
---|---|---|
off | off | on |
off | on | on |
on | off | off |
on | on | on |
Input 1 | Input 2 | Output |
---|---|---|
off | off | off |
off | on | off |
on | off | on |
on | on | on |
Input 1 | Input 2 | Output |
---|---|---|
off | off | on |
off | on | off |
on | off | on |
on | on | on |
###########
#X Y OUTPUT
#0 0 1
#0 1 0
#1 0 1
#1 1 1
###########
x = False
y = True
if (not(x or y)) ^ x:
print("on")
else:
print("off")
Input 1 | Input 2 | Input 3 | Output |
---|---|---|---|
off | off | off | on |
off | off | on | on |
off | on | off | on |
off | on | on | on |
on | off | off | off |
on | off | on | off |
on | on | off | off |
on | on | on | on |