- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Inplace operation is an operation which directly changes the content of a given linear algebra or vector or metrices without making a copy. Now the operators, which helps to do this kind of operation is called in-place operator.

Let’s understand it with an a simple example -

a=9 a += 2 print(a)

11

Above the += tie input operator. Here first, a add 2 with that a value is updated the previous value.

Above principle applies to other operators also. Common in place operators are -

- +=
- -=
- *=
- /=
- %=

Above principle applies to other types apart from numbers, for example -

language = "Python" language +="3" print(language)

Python3

Above example of x+=y is equivalent to x = operator.iadd(x,y)

There are multiple operators which are used for inplace operations.

This function is used to assign the current value and add them. This operator does x+=y operation.

x =operator.iadd(9,18) print("Result after adding: ", end="") print(x)

Result after adding: 27

This function is used to assign the current value and subtract them. Isub() function does x-=y operation.

x =operator.isub(9,18) print("Result after subtraction: ", end="") print(x)

Result after subtraction: -9

This function is used to assign the current value and multiply them. This operator does x*=y operation.

x =operator.imul(9,18) print("Result after multiplying: ", end="") print(x)

Result after multiplying: 162

This function is used to assign the current value and divide them. This operator does x/=y operation.

x =operator.itruediv(9,18) print("Result after dividing: ", end="") print(x)

Result after dividing: 0.5

this function is used to assign the current value and divide them. This operator does x %=y operation.

x =operator.imod(9,18) print("Result after moduls: ", end="") print(x)

Result after moduls: 9

This function is used to concatenate two strings.

x = "Tutorials" y = "Point" str1 = operator.iconcat(x,y) print(" After concatenation : ", end="") print(str1)

After concatenation : TutorialsPoint

This function is equivalent to x **=y.

x =operator.ipow(2,6) print("Result after exponent: ", end="") print(x)

Result after exponent: 64

Operators are the constructs which can manipulate the value of operands.

For example in the expression- 9+18 = 27, here 9 and 18 are operands and + is called operator.

**Types of Operator**

Python language supports the following types of operators -

**Arithmetic Operators**: (for example: +, -, *, /, %, **, //)**Comparision Operators**: (for example: “==”, “!=”, “<>”, “>”, “<”, “>=”, “<=”)**Assignment Operators**: (for example: “=”, “+=”, “-=”, “*=”, “/=”, “%=”, “**=”, “//=”)**Logical Operators**: (for example: “Logical AND”, “Logical OR”, “Logical NOT”)**Bitwise Operators:**(for example: “|”, “&”, “^”, “~”, “<<”, “>>”)**Membership Operators**: (for example: in, not in)**Identity Operators**: (for example: is, is not)

Below is a table showing how abstract operations correspond to operator symbols in the Python syntax and the functions in the operator module.

Operation | Syntax | Function |
---|---|---|

Addition | x + y | add(x, y) |

Concatenation | Seq1 + seq2 | Concat(seq1, seq2) |

Containment Test | Obj in seq | Contains(seq, obj) |

Division | x / y | Truediv(x, y) |

Division | x // y | Floordiv(x, y) |

Bitwise And | x & y | And_(x, y) |

Bitwise Exclusive Or | x ^ y | Xor(x, y) |

Bitwise Inversion | ~x | Invert(x) |

Bitwise Or | x|y | or_(x,y) |

Exponentiation | x ** y | pow(x, y) |

Identity | x is y | is_(x, y) |

Identity | x is not y | is_not(x, y) |

Indexed Assignment | obj[k] = v | setitem(obj, k, v) |

Indexed deletion | del obj[k] | delitem(obj, k) |

Indexing | Obj[k] | Getitem(obj,k) |

Left shift | a << b | Lshift(a,b) |

Modulo | a % b | Mod(a, b) |

Multiplication | x*y | mul(x*y) |

Matrix multiplication | x@b | Matmul(x, y) |

Negation(Arithmetic) | -a | Neg(a) |

Negation(Logical) | not a | not_(a) |

Positive | +a | pos(a) |

Right shift | a>>b | Rshift(a,b) |

Slice Assignment | Seq[i:j] =values | Setitem(seq, slice(i,j), values) |

Slice deletion | Del seq[i:j] | Delitem(seq, slice(i,j)) |

Slicing | Seq[i:j] | Getitem(seq, slice(I, j)) |

String formatting | S % obj | Mod(s, obj) |

Subtraction | a-b | Sub(a,b) |

Truth Test | obj | truth(obj) |

Ordering | a<b | lt(a,b) |

Ordering | a<=b | le(a,b) |

Equality | a == b | eq(a,b) |

Difference | a != b | ne(a,b) |

Ordering | a >= b | ge(a, b) |

Ordering | a > b | gt(a, b) |

- Related Questions & Answers
- Python Inplace Operators - iadd(), isub(), iconcat()
- Inplace Operators in Python - ixor(), iand(), ipow()
- Inplace Operators in Python - iadd(), isub(), iconcat()
- Python Standard operators as functions
- Inplace operator in Python
- IS vs AS Operators in C#
- Standard Data Types in Python
- C++ vs Java vs Python?
- List vs tuple vs dictionary in Python
- Division Operators in Python?
- Basic Operators in Python
- Overloading Operators in Python
- Python Arithmetic Operators
- Python Comparison Operators
- Python Assignment Operators

Advertisements