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),left to right
unary - (negative sign) 
*, /, %multiplication, division, remainderleft to right
+, -addition and subtractionleft to right
in, not in, is, is not,  membership and comparisonsleft to right
<, <=, >, >=, !=, ==!
notboolean not left to right
andboolean andleft to right
orboolean orleft to right

In Python 3, // (integer division) has the same precedence as *, /, and %.


Matt Bishop
Department of Computer Science
University of California at Davis
Davis, CA 95616-8562 USA
Last modified: January 9, 2018 at 10:58PM
Winter Quarter 2018
You can get a PDF version of this