Home >>Python cmath Module >Python cmath.isclose() Method

Python cmath.isclose() Method

Python cmath.isclose() Method

Python cmath.isclose() method in python is used to returns a boolan (true ot false) and checks whether two complex values are close, or not. If the values are close returns True otherwise False.

Syntax:
cmath.isclose(a, b, rel_tol = value, abs_tol = value)

Parameter Values

Parameter Description
a It is a Required parameter to check for closeness of first number
b It is a Required parameter to check for closeness of second number
rel_tol = value It is Optional parameter and is known as the relative tolerance. This parameter Default value is 1e-09
abs_tol = value It is Optional parameter and is known as the absolute tolerance. This parameter value must be 0
Here is an Example of Python cmath.isclose() Method:

import cmath 
print(cmath.isclose(5+3j, 5+3j)) 
print(cmath.isclose(5+3j, 5.01+3j))

Output:
True
False
Example 2:

import cmath 
print(cmath.isclose(5+5j, 5+7j)) 
print(cmath.isclose(5+7j, 5+38j))

Output:
False
False

No Sidebar ads