Definition &On-site operation &it is an operation that directly modifies the contents of a given linear algebra, vector, matrix (tensor) without creating a copy. Operators that help perform an operation are called an in-place operator.
For example: a + = b is equivalent to a = operator.iadd (a, b)
There are several operators used to work in place.
This function is used to assign the current value and add them. This operator performs the operation x + = y. In the case of strings, no numbers are assigned.
Example
a = operator.iadd (1, 3); print ("The result after adding:", end = "") print (a)
Output
The result after adding: 5
compile ()
This function is used to assign the current value and subtract them. This operator performs the x- = y operation. For strings, no numbers are assigned.
Example
a = operator.isub (8, 6); print ("The result after subtracting:", end = "") print (a)
Output
The result after subtracting: 2
imul ()
This function is used to assign the current value and multiply them. This operator performs the operation x * = y. For strings, no numbers are assigned.
Example
a = operator.imul (8, 6); print ("The result after multiplying:", end = "") print (a)
Output
The result after multiplying: 48
itruediv ()
This function is used to assign the current value and divide it. This operator performs the x / = y operation. For strings, no numbers are assigned.
Example
a = operator.itruediv (54, 6); print ("The result after dividing:", end = "") print (a)
Output
The result after dividing: 9
imod ()
This function is used to assign the current value and divide it. This operator performs the operation x% = y. For strings, no numbers are assigned.
Example
a = operator.imod (10, 5); print ("The result after modulus:", end = "") print (a)
Output
The result after modulus: 2.0
iconcat ()
This function is used to concatenate two lines.
Example
a = "jupyter" b = "notebook" t = operator.iconcat (a, b) print ("After concatenation:", end = "") print (t)
Output
After concatenation: jupyter notebook