# Math Functions in Python | Set 4 (Special functions and constants)

Python Methods and Functions

1. gamma () : — this function is used to return a gamma function argument.

 ` # Python code to demonstrate how it works ` ` # gamma () `   ` # import & quot; mathematics & quot; for math operations ` ` import ` ` math `   ` a ` ` = ` ` 4 `   ` # return gamma () of 4 ` ` print ` ` (` ` "The gamma () of 4 is:" ` `, end ` ` = ` ` "") ` ` print ` ` (math.gamma (a)) `

Output:

` The gamma () of 4 is: 6.0 `

2. pi : — it is a built-in constant that outputs the pi (3.141592) .

3. e : — this is a built-in constant that outputs the value e (2.718281) .

 ` # Python code to demonstrate how it works ` ` # const. pi and e `   ` # import & quot; math & quot; for math operations ` ` import ` ` math `   ` # returning const. pi number ` ` print ` ` (` ` "The value of const. pi is: "` `, end ` ` = ` `" ") ` ` print ` ` (math.pi) `   ` # returning const. e ` ` print ` ` (` ` "The value of const. e is: "` `, end ` ` = ` `" ") ` ` print ` ` (math.e) `

Output:

` The value of const. pi is: 3.141592653589793 The value of const. e is: 2.718281828459045 `

4. inf : — it is a positive floating-point infinity constant . -inf is used to denote negative floating point infinity. This constant is defined in Python 3.5 and up.

5. isinf () : — This function is used to check whether a value is infinite or not.

6. nan : — this constant means “

7. isnan () : — this function returns true if the number is "nan", otherwise it returns false.

 ` # Python code to demonstrate how it works ` ` # inf, nan, isinf (), isnan () `   ` # import "math" for math operations ` ` import ` ` math `   ` # check if the number is nan ` ` if ` ` (math.isnan (math.nan)): ` ` print ` ` (` ` "The number is nan" ` `) ` ` else ` `: ` ` print ` ` (` ` "The number is not nan" ` `) `   ` # check if the number is positive infinity ` ` if ` ` (math.isinf (math.inf)): ` ` ` print ` (` ` "The number is positive infinity" ` `) ` ` else ` `: ` ` print ` ` (` ` "The number is not positive infinity" ` `) `

Output:

` The number is nan The number is positive infinity `