invert() function in python by R4R Team

- invert() is a python function predefined in operator module.
-It work on the numeric value, it find the negation of the given number.

Syntax-

operator.invert(number)

Example-

operator.invert(3) will give -4
operator.invert(0) will give -1
operator.invert(-12) will give 11
operator.invert(-1) will give 0


program-

import operator
#invert the positive number
print(operator.invert(12))
print(operator.invert(2))
print(operator.invert(1))
print(operator.invert(0))
print(operator.invert(245))

#invert the negative number
print(operator.invert(-12))
print(operator.invert(-1))
print(operator.invert(-123))
print(operator.invert(-245))


output-

-13
-3
-2
-1
-246
11
0
122
244


-In this program, we find the negation of the number by using the invert() function.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!