Consider the given expression:
not True and False or True
Which of the following will be correct output if the given expression is evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
Answer:
On evaluating the given expression, the output given is True .
So, the correct answer is (a).
Explanation:
And, or and not are the three logical operators in the above expression.
The truth tables for the 3 operators are:
a. and
b. or
c. not
Evaluating the given expression:
Step 1: not True gives False. So the expression becomes ‘ False and False or True ’.
Step 2: False and False give False. So the expression becomes ‘ False or True ’.
Step 3: False or True gives True. So the expression becomes ‘ True’.
Therefore, the output will be True if the given expression is evaluated.