欢迎光临
我们一直在努力

python怎么引入sqrt函数

在python中引入sqrt函数的方法

在python中使用sqrt函数时,sqrt()函数无法直接访问,需要先导入math模块,在通过静态对象调用;

sqrt():sqrt函数的作用是返便宜美国vps回一个数的平方根。

sqrt()函数语法:

import math

math.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.64575131106

math.sqrt(math.pi) : 1.77245385091

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。