Logic Gates
Use: logic.ly
Question 1
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")
Question 2
Input 1 | Input 2 | Output |
---|---|---|
off | off | on |
off | on | on |
on | off | off |
on | on | on |
Question 3
Input 1 | Input 2 | Output |
---|---|---|
off | off | off |
off | on | off |
on | off | on |
on | on | on |
Question 4
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")
Question 5
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 |