In this tutorial you will learn about operators in python and it’s types which is symbol used to perform specific mathematical and logical manipulation.

## Types of operators

**Arithmetic operato**r

Arithmetic operator is basically used to perform mathematical computation like addition, subtraction, multiplication and division.

Operator | Meaning | Example |

+ | Add two operands or unary plus | *n+n +5 |

– | Subtract or unary minus | m-n -10 |

* | Multiply two operand | m*n |

/ | divide (Result is in float) | m/n |

% | Modulus (Return Remainder) | m%n |

// | Floor division (Return whole number) | m//n |

** | Exponent (Left operand raised to power of right) | m**n (m to the power of y) |

**Examples :**

m=10 n=4 print("m+n=",m+n) print("m-n=",m-n) print("m*n=",m*n) print("m/n=",m/n) print("m//n=",m//n) print("m**n=",m**n)

**Output:**

m+n=14 m-n=6 m*n=40 m/n=2.5 m//n=2 m**n=10000

**Comparison operator**

The operator which is used to compared two or more values is known as comparison operator. It return True or False boolean value according to condition.

Operator | Meaning | Example |

> | Greater than | m>n |

< | Less than | m<n |

== | Equal to | m==n |

!= | not equal to | m!=n |

>= | Greater than or equal to | m>=n |

<= | Less than or equal to | m<=n |

**Examples:**

m=15 n=5 print("m>n=",m>n) print("m<n=",m<n) print("m==n=",m==n) print("m!=n=",m!=n) print("m>=n=",m>=n) print("m<=n=",m<=n)

**Output :**

m>n=True m<n=False m==n=False m>=n=True m<=n=False

**Logical operator**

Logical operator are operator which is used for conditioning a statement. ‘and, or, not ‘ are logical operator.

Operator | Meaning | Example |

And | True if both operands are true | m and n |

Or | True if any one operands are true | m or n |

Not | True if operand is false | not m |

**Example :**

x=True y=False print(m and y) print(m or y) print(not m)

**Output :**

**False
True
False**

**Bitwise operator**

Operator | Meaning | Example |

| | Bit wise OR | 2|2=1 |

& | Bit wise AND | 2&2=4 |

^ | Bit wise XOR | 5^3=6 |

**Assignment operator**

Operator | Meaning | Example |

= | x=10 | x=10 |

+= | x+=10 | x=x+10 |

-= | x-=10 | x=x-10 |

/= | x/=10 | x=x/10 |

*= | x*=10 | x=x*10 |

%= | x%=10 | x=x%10 |

//= | x//=10 | x=x//10 |

**= | x**=10 | x=x**10 |

Was this article helpful?

YesNo