# Assignment Operator

## ‘=’ operator

The equal to operator ‘=’ assigns the value of the right operand to the left operand. Have a look at the following piece of code, a and b are two variables having different values. However, when we say ‘a=b’ the value of b is assigned to a .

```a = 10;
b = 15;
print ('a = 10 and b = 15')
a = b
print ('if a = b then the value of "a"  will change to:')
print (a)
```

## ‘+=’ operator

The ‘+=’ operator is also known as Add AND operator. It adds the values of the left and the right operands and assigns the result to the left operand. In the following example a+= b is same as a=a+b.

```a = 10;
b = 15;
print ('a = 10 and b = 15')
a += b
print ('if a += b then the value of "a"  will change to:')
print (a)
```

## ‘-=’ operator

The ‘-=’ operator is also known as Subtract AND operator. It subtracts the value of the right operand from the value of the left operand and assigns the result to the left operand.Have a look at the following example a-=b is same as a=a-b.

```a = 10;
b = 15;
print ('a = 10 and b = 15')
a -= b
print ('if a -= b then the value of "a"  will change to:')
print (a)
```

## ‘*=’ operator

The ‘*=’ operator is also known as Multiply AND operator. It multiplies the value of the right and the left operand and assigns the result to the left operand. In the following example a*=b is same as a=a*b.

```a = 10;
b = 15;
print ('a = 10 and b = 15')
a *= b
print ('if a *= b then the value of "a"  will change to:')
print (a)
```

## ‘/=’ operator

The Divide AND operator – ‘/=’ operator with divide the value of the left operand with the value of the right operand and will assign the result to the left operand. In the following example a/=b is same as a=a/b.

```a = 10;
b = 2;
print('a = 10 and b = 2')
a /= b
print ('if a/=b then the value of "a"  will change to:')
print (a)
```

## ‘%=’ operator

The Modulus AND operator – ‘%=’ operator with divide the value of the left operand with the value of the right operand and will assign value of the modulus to the left operand. In the following example a%=b is same as a= a%b.

```a = 10;
b = 2;
print ('a = 10 and b = 2')
a %= b
print ('if a %= b then the value of "a"  will change to:')
print (a)
```

## ‘**=’ operator

‘**=’ operator is also known as the exponent AND operator. It finds the value of the left operand raised to the power of the right operand and then assign the result to the left operand. In the following example a**=b is same as a= a raised to the power of b.

```a = 10;
b = 2;
print ('a = 10 and b = 2')
a **= b
print ('if a **= b then the value of "a"  will change to:')
print (a)
```

## ‘//=’ operator

‘//=’ operator is also known as the Floor division AND operator. It will perform the floor division between the two values and assign the result to the left operand. In the following example a//=b is same as a = a//b.

```a = 10;
b = 2;
print ('a = 10 and b = 2')
a //= b
print ('if a//=b then the value of "a"  will change to:')
print (a)
```
<<< Comparison OperatorsPython membership and identity operators >>>