Table of Precedence and Associativity

This table shows the precedence and associativity of the arithmetic, relational, and logical operators from highest to lowest precedence.

OperationDescriptionAssociativity
()parentheses for groupingleft to right
**exponentiationright to left
+, - unary + (positive sign), unary − (negative sign)left to right
*, /, //, %multiplication, division, remainderleft to right
+, -addition and subtractionleft to right
in, not in, is, is not,
<, <=, >, >=, !=, ==
membership and comparisonsleft to right
notboolean notleft to right
andboolean andleft to right
orboolean orleft to right


Matt Bishop
Department of Computer Science
University of California at Davis
Davis, CA 95616-8562 USA
Last modified: Version of January 8, 2019 at 8:17PM
Winter Quarter 2019
You can get a PDF version of this