python中sqrt的意思_Python中sqrt函数怎么用

Python中sqrt函数怎么用?下面给大家带来sqrt函数的相关介绍:

Python数字sqrt()函数返回x的平方根(x > 0)。

语法

以下是sqrt()方法的语法 -

import math

math.sqrt( x )

注意 - 此函数不可直接访问,需要导入math模块,然后需要使用math静态对象调用此函数。

参数

x - 这是一个数字表达式。

返回值

该方法返回x的平方根(x > 0)。

sqrt() 方法返回数字x的平方根。

实例import math # 导入 math 模块

print ("math.sqrt(100) : ", math.sqrt(100))

print ("math.sqrt(7) : ", math.sqrt(7))

print ("math.sqrt(math.pi) : ", math.sqrt(math.pi))

以上实例运行后输出结果为:math.sqrt(100) : 10.0

math.sqrt(7) : 2.6457513110645907

math.sqrt(math.pi) : 1.7724538509055159

你可能感兴趣的:(python中sqrt的意思)