Q.Consider the given expression : 7<4 or 6>3 and not 10==10 or 17>4 Which of the following will be the correct output if the given expression is evaluated ?
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Evaluate the boolean expression left-to-right respecting operator precedence: not binds tightest, then and, then or. The expression evaluates to True.
This is a question about operator precedence in boolean logic, exactly as implemented in most programming languages (Python, C, Java). You need to know which operators "grab" their operands first.
The precedence hierarchy for logical operators is:
not(highest - unary, binds to the immediate right)and(middle - binary)or(lowest - binary)
Think of it like arithmetic: not behaves like exponentiation, and like multiplication, and or like addition. Just as 2 + 3 * 4 means 2 + (3 * 4), the expression A or B and C means A or (B and C).
Let me parse the given expression step by step.
Given: 7<4 or 6>3 and not 10==10 or 17>4
-
Evaluate all comparison operators first (they have higher precedence than logical operators):
7 < 4->False6 > 3->True10 == 10->True17 > 4->True
So the expression becomes:
False or True and not True or True -
Apply
not(highest precedence among logical operators):not True->False
Now we have:
False or True and False or True -
Apply
and(next precedence):The
andoperator sits betweenTrueandFalse:True and False->False…
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.