← Quiz: Boolean Algebra and Logic: all 10 questions
Quiz: Boolean Algebra and Logic · Question 8 of 10
What does this print? (code)
What does this print?
nand = lambda x, y: 1 - (x & y)
print([nand(nand(x, x), nand(y, y)) for x in (0, 1) for y in (0, 1)])
- A.[0, 0, 0, 1]
- B.[1, 1, 1, 0]
- C.[0, 1, 1, 1]
- D.[1, 0, 0, 0]
Answer & explanation
Correct answer: [0, 1, 1, 1]
nand(x, x) is NOT x, and NOT x NAND NOT y is x OR y by De Morgan's law.
Can you get the rest right without peeking?
Take the timed Quiz: Boolean Algebra and Logic quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →