Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python cmath.isinf() function is used to return True if either the real or the imaginary part of a given complex number is an infinity, and False otherwise.

Syntax

cmath.isinf(x)   

Parameters

x Required. Specify the value.

Return Value

Returns true if either the real or the imaginary part of the argument is an infinity, and false otherwise.

Example:

The below example shows the usage of isinf() function.

import cmath

print(cmath.isinf(2 + 2j))
print(cmath.isinf(-2))
print(cmath.isinf(1.5j))

print(cmath.isinf(float("nan")))
print(cmath.isinf(float("inf")))
print(cmath.isinf(float("-inf")))

The output of the above code will be:

False
False
False

False
True
True

❮ Python cMath Module