isinf()
function exists in Standard math Library of Python Programming Language and is used to determine whether a specific number is an infinite number or not.
Syntax of isinf()
The syntax of
isinf()
function in python is:math.isinf( x )
Parameters of isinf()
x
Any valid Python number (positive or negative). This parameter is required.Note: if the
x
parameter is not a number, isinf()
function will return an error
.
Python isinf()
Function Compatibility
Python 2.x – Yes
Python 3.x – Yes
Python 3.x – Yes
Return Value of isinf()
The return value of
isinf()
function is either True
or False
.
If parameter x
is infinite, isinf()
function returns True
.
If Parameter x
is neither an infinity nor a NaN (Not a Number in computing), isinf()
returns False
.
Python isinf()
Function Example
# import math library import math print(math.isinf(2)) print(math.isinf(0.0)) # Python considered 0.0 as finite number print(math.isinf(0/1)) print(math.isinf(0.0/1)) print(math.isinf(-500))
Output of Python isinf()
function:
False
False
False
False
False