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

Python math.isclose() Method

Python math.isclose() Method

Python math.isclose() method in python is used to returns a Boolean value(True if the values are close, otherwise False). Basically, in other words it checks whether two values are close, or not.

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

Parameter Values

Parameter Description
a It is Required the value (first value) to check for closeness
b It is Required the value (second value) to check for closeness
rel_tol = value It is Optional and used for relative tolerance. Its Default value is equal to 1e-09
abs_tol = value It is Optional and is used for the minimum absolute tolerance. The value must be at least 0
Here is an Example of Python math.isclose() Method:

import math  
print(math.isclose(0.345, 1.6354))
print(math.isclose(1.6354, 1.6354))
print(math.isclose(1.6354, 1.63540072))

Output:
False
True
False
Example 2:

import math  
print(math.isclose(4.7628, 6.8734, abs_tol = 0.8))
print(math.isclose(6.8734, 3.2837, abs_tol = 0.8))

Output:
False
False

No Sidebar ads