# Python | Decimal boolean_invert () method

Python Methods and Functions

Decimal # logic_invert (): logic_invert () — it is a method of the Decimal class that returns bitwise inversion of decimal values.

Syntax: Decimal.logical_invert()

Parameter: Decimal values ​​

Return: the digit-wise inversion of the Decimal values.

Code # 1: Example for logic_invert () method

 ` # Python program explaining ` ` # logic_invert ( ) method `   ` # loading decimal library ` ` from ` ` decimal ` ` import ` ` * `     ` # Initialize decimal value ` ` a ` ` = ` ` Decimal (` `' 0' ` `) `   ` b ` ` = ` ` Decimal (` ` '1' ` `) ` ` `  ` # print decimal values ​​` ` print ` ` (` ` "Decimal value a:" ` `, a) ` ` print ` ` (` ` "Decimal value b:" ` `, b) `     ` # Using the Decimal.logical_invert () method ` ` print ` ` (` `" Decimal a with logical_invert () method: "` `, a.logical_invert ()) `   ` print ` ` (` ` "Decimal b with logical_invert () method:" ` `, b.logical_invert ()) `

Output:

` Decimal value a: 0 Decimal value b: 1 Decimal a with logical_invert () method: 11111111111111111111111111 Decimal b with logical_invert () method: 1111111111111111111111111110 `

Code # 2: Example for logic_invert () method

 ` # Python program explaining ` ` # logic_invert () method `   ` # download decimal library download ` ` from ` ` decimal ` ` import ` ` * `     ` # Initialize decimal value ` ` a ` ` = ` ` Decimal (` ` '1' ` `) `   ` b ` ` = ` ` Decimal (` ` '0' ` `) `   ` # print decimal values ​​` ` print ` ` (` ` "Decimal value a:" ` `, a) ` ` print ` ` (` `" Decimal value b: "` `, b) `     ` # Using the Decimal.logical_invert () method ` ` print ` ` (` ` "Decimal a with logical_invert () method:" ` `, a.logical_invert ()) `   ` print ` ` (` `" Decimal b with logical_invert () method: "` `, a.logical_invert ()) `

Output:

` Decimal value a: 1 Decimal value b: 0 Decimal a with logical_invert () method: 1111111111111111111111111110 Decimal b with logical_invert () method: 1111111111111111111111111110 `