##### Top Python Operator

A Python operator is a symbol that performs an operation on one or greater operands. An operand is a variable or a price on which we perform the operation. data science with python training

__Introduction to Python Operator__

Python Operator falls into 7 classes:

- Python Arithmetic Operator
- Python Relational Operator
- Python Assignment Operator
- Python Logical Operator
- Python Membership Operator
- Python Identity Operator
- Python Bitwise Operator
- Python Arithmetic Operator

These Python arithmetic operators consist of Python operators for fundamental mathematical operations.

**a. Addition(+)**

Adds the values on either aspect of the operator.

>>> 3+4

Output: 7

**b. Subtraction(-)**

Subtracts the price on the proper from the only at the left.

>>> 3-4

Output: -1

**c. Multiplication(*)**

Multiplies the values on either aspect of the operator.

>>> 3*4

Output: 12

**d. Division(/)**

Notice that department results in a floating-factor price.

>>> ¾

Output: 0.75

**e. Exponentiation(**)**

Raises the primary variety to the power of the second one.

>>> 3**4

Output: 81

**f. Floor Division(//)**

>>> 3//4

>>> 4//3

Output: 1

>>> 10//3

Output: 3

**g. Modulus(%)**

Divides and returns the value of the remainder.

>>> 3%4

Output: three

>>> 4%3

Output: 1

>>> 10p.C3

Output: 1

>>> 10.5%3

Output: 1.5

If you face any query in Python Operator with examples, ask us in the remark.

__Python Relational Operator__

Let’s see Python Relational Operator.

Relational Python Operator includes out the comparison among operands. They inform us whether an operand is more than the alternative, lesser, identical, or a mixture of these.

**a. Less than(<)**

This operator checks if the value on the left of the operator is lesser than the one on the right.

>>> 3<4

Output: True

**b. Greater than(>)**

It checks if the value on the left of the operator is more than the only on the right.

>>> 3>4

Output: False

**c. Less than or equal to(<=)**

It checks if the value on the left of the operator is lesser than or equal to the one on the right.

>>> 7<=7

Output: True

**d. Greater than or equal to(>=)**

It assessments if the fee on the left of the operator is more than or same to the only at the proper.

>>> 0>=0

Output: True

**e. Equal to(= =)**

This operator tests if the price on the left of the operator is equal to the one on the proper. 1 is same to the Boolean value True, but 2 isn’t. Also, 0 is identical to False.

>>> 3==3.0

Output: True

>>> 1==True

Output: True

>>> 7==True

Output: False

>>> 0==False

Output: True

>>> 0.5==True

Output: False

**f. Not identical to(!=)**

It assessments if the price at the left of the operator isn’t always same to the one on the right. The Python operator <> does the equal task, but has been deserted in Python 3.

When the situation for a relative operator is fulfilled, it returns True. Otherwise, it returns False. You can use this go back value in a further announcement or expression.

>>> 1!=1.0

Output: False

>>> -1<>-1.0

#This causes a syntax errors

__Python Assignment Operator__

Assignment Python Operator explained –

An project operator assigns a cost to a variable. It can also manipulate the cost by using a component before assigning it. We have 8 venture operators- one plain, and seven for the 7 mathematics python operators.

**a. Assign(=)**

Assigns a price to the expression at the left. Notice that = = is used for evaluating, however = is used for assigning.

>>> a=7

>>> print(a)

Output: 7

**b. Add and Assign(+=)**

Adds the values on both facet and assigns it to the expression on the left. A+=10 is similar to a=a+10.

The identical is going for all the subsequent challenge operators.

>>> a+=2

>>> print(a)

Output: 9

**c. Subtract and Assign(-=)**

Subtracts the fee at the proper from the price on the left.

>>> a-=2

>>> print(a)

Output: 7

**d. Divide and Assign(/=)**

Divides the price at the left through the only at the proper.

>>> a/=7

>>> print(a)

Output: 1.0

**e. Multiply and Assign(*=)**

Multiplies the values on either aspects. Then it assigns it to the expression at the left.

>>> a*=8

>>> print(a)

Output: 8.0

**f. Modulus and Assign(%=)**

Performs modulus on the values on either aspect. Then it assigns it to the expression at the left.

>>> a%=3

>>> print(a)

Output: 2.0

**g. Exponent and Assign(**=)**

Performs exponentiation on the values on both aspect. Then assigns it to the expression at the left.

>>> a**=5

>>> print(a)

Output: 32.0

**h. Floor-Divide and Assign(//=)**

Performs ground-division at the values on either facet. Then assigns it to the expression at the left.

>>> a//=3

>>> print(a)

Output: 10.0

This is one of the critical Python Operator.

__Python Logical Operator__

We have three Python logical operator – and, or, and now not that come under python operators.

**a. And**

If the situations on each the perimeters of the operator are real, then the expression as a whole is real.

>>> a=7>7 and a pair of>-1

>>> print(a)

Output: False

**b. Or**

The expression is fake only if both the statements across the operator are fake. Otherwise, it’s far proper.

>>> a=7>7 or 2>-1

>>> print(a)

Output: True

‘and’ returns the first False cost or the final value; ‘or’ returns the first True cost or the remaining fee

>>> 7 and 0 or five

Output: 5

**c. Not**

This inverts the Boolean price of an expression. As you could see underneath, the Boolean value for zero is False. So, not inverts it to True.

>>> a=no longer(zero)

>>> print(a)

Output: True

__Membership Python Operator__

These operators check whether or not a fee is a member of a series. The sequence may be a listing, a string, or a tuple. We have two club python operators- ‘in’ and ‘not in’.

**a. In**

This tests if a price is a member of a chain. In our instance, we see that the string ‘fox’ does no longer belong to the list pets. Also, the string ‘me’ is a substring to the string ‘unhappiness’. Therefore, it returns actual.

>>> pets=[‘dog’,’cat’,’ferret’]

>>> ‘fox’ in pets

Output: False

>>> ‘cat’ in pets

Output: True

>>> ‘me’ in ‘disappointment’

Output: True

**b. Not in**

Unlike ‘in’, ‘no longer in’ assessments if a fee isn’t a member of a sequence.

>>> ‘pot’ no longer in ‘unhappiness’

Output: True

We looked at seven distinct lessons of Python operator. We accomplished them inside the Python Shell(IDLE) to discover how they paintings. We can similarly use this operator in situations, and to combine them.