🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Logic: all 10 questions

Quiz: Logic · Question 8 of 10

What does this print? (code)

What does this print?

from itertools import product
rows = [(p, q) for p, q in product([True, False], repeat=2)
        if ((not p) or q) and ((not q) or p)]
print(len(rows))
  1. A.1
  2. B.2
  3. C.3
  4. D.4
Answer & explanation

Correct answer: 2

(p → q) ∧ (q → p) is the biconditional, true when p and q have the same value: 2 rows.

Can you get the rest right without peeking?

Take the timed Quiz: Logic quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →