Python – Operators:

Operators in Python helps us to perform the mathematical operations with numbers. There are different operators in Python as below.

Operators Description
// Integerdivision
+ addition
* multiplication
/ Float division
% Provide remainder after division(Modulus)
** Perform exponent (raise to power)

Let us try implementing every operator now.

  1. Addition: symbol used (+)


  1. Substration: symbol used (-)


  1. multiplication: Symbol used (*)

  1. Float Division: This will divide and provide the result in floating value and the symbol used (/)

  1. Integer Division: This will divide and truncate the decimal and provide the Integer value and the symbol used (//)

  1. Exponentiation Operator: This will help us to calculate a power b and return the result

  1. Modulus Operator: This will provide the remainder after the calucation and symbol used (%)

What if we want to work with multiple operators at a time. Here comes the Operator precedence in Python.

Operator Description
lambda Lambda expression
if – else Conditional expression
or Boolean OR
and Boolean AND
not x Boolean NOT
in, not in, is, is not, <, <=, >, >=, !=, == Comparisons, including membership tests and identity tests
| Bitwise OR
^ Bitwise XOR
& Bitwise AND
<<, >> Shifts
+, – Addition and subtraction
*, @, /, //, % Multiplication, matrix multiplication division, remainder [5]
+x, -x, ~x Positive, negative, bitwise NOT
** Exponentiation [6]
await x Await expression
x[index], x[index:index], x(arguments…), x.attribute Subscription, slicing, call, attribute reference
(expressions…), [expressions…], {key: value…}, {expressions…} Binding or tuple display, list display, dictionary display, set display