Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

math.sqrt

Returns the nonnegative real square root of its argument.

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

Syntax

math.sqrt(x, /)

Returns the nonnegative real square root of its argument.

Zero is allowed. For a strictly negative real operand the real-valued function raises ValueError.

The real square root of 81 is 9.0 because 9² = 81 and the principal root is nonnegative. Zero has root 0.0. A strictly negative argument raises ValueError; the complex square root belongs to cmath.sqrt.

import math
assert math.sqrt(81) == 9.0 and type(math.sqrt(0)) is float
assert math.sqrt(0) == 0.0

Examples

import math
print(math.sqrt(81))
print(math.sqrt(0))

Result

9.0
0.0

The real square root of 81 is 9.0 because 9² = 81 and the principal root is nonnegative. Zero has root 0.0. A strictly negative argument raises ValueError; the complex square root belongs to cmath.sqrt.

Sources