Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Module math

Provides real-number mathematics, including floating-point functions, constants and exact integer operations.

Version: Python 3.14; repository image, production runtime not attested

Syntax

math.isclose(a, b, rel_tol=..., abs_tol=...)

Provides real-number mathematics, including floating-point functions, constants and exact integer operations.

Use isqrt for an exact floor square root and isclose for tolerance-based comparison. Near zero a positive absolute tolerance may be needed.

The real-valued sqrt raises ValueError on a negative number.

Examples

import math
print(math.isqrt(99), math.isclose(0.1 + 0.2, 0.3))
print(math.isclose(1e-12, 0), math.isclose(1e-12, 0, abs_tol=1e-11))
try:
    math.sqrt(-1)
except ValueError:
    print("outside real domain")

Result

9 True
False True
outside real domain

The real-valued sqrt raises ValueError on a negative number.

Sources