Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.sqrt() Function

Python math.sqrt() Function

Python math Module Python math Module

Python math.sqrt(x) The function returns the square root of x.

The number must be greater than or equal to 0.

Syntax

The syntax of the math.sqrt() function is as follows:

math.sqrt(x)

Parameter Description:

Return Value

Returns a floating-point number representing the square root of a number.

Example

The following example returns the square root of numbers:

Example

Import the math package

import

math

Output the square root

print

(

math

.

sqrt

(

9

)

)

print

(

math

.

sqrt

(

25

)

)

print

(

math

.

sqrt

(

16

)

)

Output result:


3.0
5.0
4.0

Python math Module Python math Module