What are the operators in Python

Operators in Python

The following table lists the operators in Python and their meaning and precedence.

Operator Description Precedence
lambda Lambda expression 1
or Logical or 2
and Logical and 3
not Logical negation 4
in Membership test 5
not in Negative membership test5
is Identity test 6
is not Negative identity test 6
< Less than7
> Greater than 7
<= Less than or equal to 7
>= Greater than or equal to7
== Equal to 7
!= Not equal to 7
| Bitwise or 8
^ Bitwise exclusive or 9
& Bitwise and 10
<< Left shift 11
>> Right shift 11
+ Addition 12
- Subtraction 12
* Multiplication13
/ Division 13
% Remainder13
+ Unary identity14
- Unary negation14
~ Bitwise complement 15
** Exponentiation16
x.attribute Attribute reference17
x[index] Subscription 18
x[index1:index2[:index3]]Slicing 19
f(args...)Function call 20
(...)Parenthesized expression or tuple display 21
[...]List display 22
{key:value, ...} Dictionary display 23
`expressions...` String conversion 24




















Home »
  Python »
    Language Basics »




Python Basics
Operator
Statements
Function Definition
Class
Buildin Functions
Buildin Modules