码迷,mamicode.com
首页 > 其他好文 > 详细

20170430 math.sqrt函数

时间:2017-04-30 12:43:04      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:int   tty   平方根   class   pretty   ret   mod   数字   str   

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

 

语法:

import math

math.sqrt( x )

注意:sqrt()是不能直接访问的,需要导入 math 模块,通过静态对象调用该方法。

 

import math # This will import math module

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

20170430 math.sqrt函数

标签:int   tty   平方根   class   pretty   ret   mod   数字   str   

原文地址:http://www.cnblogs.com/Jiang190/p/6788910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!