math.isclose()
math.isclose() is a Python function in the Math Module category. Returns True if a and b are close to each other (for floating-point comparisons). The syntax is math.isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0). Returns: Boolean. A typical example: math.isclose(0.1 + 0.2, 0.3) # True
math.isclose(0.1 + 0.2, 0.3, rel_tol=1e-5) # True. A close sibling is math.ceil(), which returns the smallest integer greater than or equal to x. A close sibling is math.floor(), which returns the largest integer less than or equal to x. A close sibling is math.trunc(), which truncates the fractional part, returning the integer part. A close sibling is math.fabs(), which returns the absolute value of x as a float. More about this category: Mathematical functions — sin, cos, sqrt, floor, ceil, and constants. For a broader walkthrough, read the Math Module guide. Related Math Module entries: math.ceil(), math.floor(), math.trunc(), math.fabs(), math.sqrt(), math.pow().