value + value

The Plus operator performs addition on numbers or concatenation on strings, lists and tuples.

value – value

The Minus operator performs subtraction on numbers.

value * value

The Multiplication operator performs multiplication on numbers. If you multiply a string, 's', by a number, 'n', you get 'n' copies of 's' concatenated together.

value / value

The Divide operator performs division on numbers.

value // value

The Div operator performs “integer division” on numbers, producing a result such that x // y == floor(x / y) for all numbers x and y .

value % value

The Modulus operator gives the “remainder after division” of its arguments, such that x == y * (x // y) + x % y for all numbers x and y . If the left operand is a string, it performs “interpolation” with either a single value or a list/tuple of values and is used to generate formatted output. See the String Interpolation section for details.

value ** value

The Power operator performs exponentiation on numbers.

value & value

The Binary And operator performs bit-wise AND on integers.

value | value

The Binary Or operator performs bit-wise OR on integers.

value ^ value

The Binary Xor operator performs bit-wise XOR on integers.

value << value

The Left Shift operator does bit-wise left shift on integers.

value >> value

The Right Shift operator does bit-wise left shift on integers.

not value

The Boolean Not operator yields True if its argument is False, False otherwise. That is, if the operand is one of the True values, then Not returns False (which is 0), and if the operand is a False value, then Not returns True (which is 1).

a and b

The Boolean And operator first evalutes a. If that is False, then its value is returned. Otherwise, the value of b is returned.

a or b

The Boolean And operator first evalutes a. If that is True, then its value is returned. Otherwise, the value of b is returned.

a is b

True if a and b are the same object.

a is not b

True if a and b are not the same object.

a in b

True if a is contained in b. For strings, this means that a is a substring of b. If b is a tuple or list, this means that a is one of the elements of b. If b is a dictionary, this means that a is one of the keys of b.

a not in b

This is the same as not (a in b) .

~ value

The Binary Not operator performs a bit-wise NOT operation on its integer operand.

– value

When used as a unary prefix operator, the Unary Minus operator performs negation on numbers.

+ value

When used as a unary prefix operator, the Unary Plus operator does nothing at all to a number.

value [ index ]

The Index operator selects the index-th member of strings, lists, tuples and dictionaries.

[ value [ , value … ] ]

The List operator creates a new List with the provided members. Note that a List of one value does not have any comma after the value and is distinguished from the Index operator solely by how it appears in the input.

( value )

Parenthesis serve to control the evaluation order within expressions. Values inside the parenthesis are computed before they are used as values for other operators.

( value , ) or ( value [ , value … ] )

The Tuple operator creates a new Tuple with the provided members. A Tuple of one value needs a trailing comma so that it can be distinguished from an expression inside of parenthesis.

{ key : value [ , key : value … ] }