+

# Python | The decimal method is_normal ()

Decimal # is_normal (): is_normal () — it is a method of the Decimal class that checks if a Decimal value is a normal finite number.

Syntax: Decimal.is_normal ()

Parameter: Decimal values ​​

Return: true - if the Decimal value is a normal finite number; otherwise false

Code # 1: Example for the is_normal () method

` `

` # Program Python explaining # is_normal () method   # decimal library loading from decimal import *     # Initialize decimal value a = Decimal ( - 1 )   b < / code> = Decimal ( `-inf` )   # print decimal values ​​ print ( "Decimal value a:" , a) print ( "Decimal value b:" , b)      # Using the Decimal.is_normal () method print ( "Decimal a with is_normal () method:" , a.is_normal ())   print ( "Decimal b with is_normal () method:" , b.is_normal ()) `

` `

Output:

` Decimal value a: -1 Decimal value b: -Infinity Decimal a with is_normal () method: True Decimal b with is_normal () method: False `

Code # 2: Example for a method is_normal ()

 ` # Python program explaining ` ` # is_normal () method `   ` # decimal library loading ` ` from ` ` decimal ` ` import ` ` * `     ` # Initialize the decimal value ` ` a ` ` = ` ` Decimal (` `` -3.14` ` `) `   ` b ` ` = ` ` Decimal ( ` ` `321e + 5` ` `) ` ` `  ` # print decimal values ​​` ` print ` ` (` `" Decimal value a: "` `, a) ` ` print ` ` (` ` "Decimal value b:" ` `, b) `     ` # Using the Decimal.is_n method ormal () ` ` print ` ` (` ` "Decimal a with is_normal () method: "` `, a.is_normal ()) ` `  `` print ( "Decimal b with is_normal () method : " , b.is_normal ()) `

Output:

` Decimal value a: -3.14 Decimal value b: 3.21E + 7 Decimal a with is_normal () method: True Decimal b with is_normal () method: True `