[Solved] Boolean , what is the correct answer and why? [closed]


According to the De Morgan’s law, not (A and B) is not A or not B.

You can verify this using simple python script:

In [1]: def test(fn):
   ...:     for beta in [False, True]:
   ...:         for gamma in [False, True]:
   ...:             print(f'beta: {beta}, gamma: {gamma}, ans: {fn(beta, gamma)}')
   ...:

In [2]: test(lambda beta, gamma: not (beta and gamma))
beta: False, gamma: False, ans: True
beta: False, gamma: True, ans: True
beta: True, gamma: False, ans: True
beta: True, gamma: True, ans: False

In [3]: test(lambda beta, gamma: not beta or not gamma)
beta: False, gamma: False, ans: True
beta: False, gamma: True, ans: True
beta: True, gamma: False, ans: True
beta: True, gamma: True, ans: False

In [4]: test(lambda beta, gamma: not beta and not gamma)
beta: False, gamma: False, ans: True
beta: False, gamma: True, ans: False
beta: True, gamma: False, ans: False
beta: True, gamma: True, ans: False

solved Boolean , what is the correct answer and why? [closed]