Python‎ > ‎operator‎ > ‎

operator.inv()

http://www.adilwaseem.com/

Introduction
The method return with value of same as ~a.

Syntax
operator.inv(a)
__inv__

Parameter
a=number

Import module
Importing module is required in the Shell window and the Editor window.

Examples
The operator.inv(a) return with:
 >>> operator.inv(33)
-34
>>> operator.inv(-22)
21
>>> operator.inv(0)
-1
>>> operator.inv(100)
-101

__inv__
The method also return the same value.
>>> operator.__inv__(pow(2,3))
-9

It also equal to:
 >>> operator.__inv__(abs(-1))
-2

The method apply to round().
>>> operator.__inv__(round(-1.19))
0
>>> operator.__inv__(round(101.12))
-102
>>>

The method tested whether two methods are equal.
 >>> a=operator.invert(-22)
>>> b=operator.inv(-22)
>>> a.__eq__(b)
True
>>>


Comments