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 grouping left to right
** exponentiation right to left
+, -unary + (positive sign), unary - (negative sign)  left to right
*, /, //, %multiplication, division, remainderleft to right
+, - addition and subtraction left to right
in, not in, is, is not, <, <=, >, >=, !=, ==   membership and comparisons left to right
not boolean not left to right
and boolean and left to right
or boolean or left to right


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
MHI 289I, Programming in Health Informatics
Version of September 26, 2022 at 10:09M

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh