Python‎ > ‎operator‎ > ‎

operator.neg()


Definition
Return the value in negative.

Syntax

Parameters

Examples
The operator method return the value to negative.
 >>>import operator
>>>variable_a=39
>>> operator.neg(variable_a)
-39

__neg__
The return is:
 >>>variable_a=39
>>> operator.__neg__(variable_a)
-39

operator.neg(random)
The return with negative random value.
import operator
import random
random1=random.random()
print(operator.neg(random1))
>>> 
-0.9279674230152819
>>> 

Comments