Correct option is D
The correct precedence of operators in Python is:
Braces, not, and, or. This means that operations inside parentheses (braces) are evaluated first, followed by the logical not operator, then and, and finally or, which has the lowest precedence.
Important Key Points:
1.
Braces (Parentheses): Operations inside parentheses have the highest precedence and are evaluated first.
2.
not Operator: The not operator has a higher precedence than and and or.
3.
and Operator: The and operator has a higher precedence than or.
4.
or Operator: The or operator has the lowest precedence among the logical operators.
5.
Order of Evaluation: Python evaluates expressions from left to right, but the operator precedence determines the order in which sub-expressions are computed.
Knowledge Booster:
·
Option (a): This is incorrect because
or has a lower precedence than
and, so the precedence order is wrong.
·
Option (b): This is incorrect because
not has higher precedence than
Braces, and
or has lower precedence than
and.
·
Option (c): This is incorrect because, while
not has the highest precedence,
or should be evaluated last, not before
and.