本文整理汇总了Python中Math.sqrt方法的典型用法代码示例。如果您正苦于以下问题:Python Math.sqrt方法的具体用法?Python Math.sqrt怎么用?Python Math.sqrt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math.sqrt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: guessing_game
# 需要导入模块: import Math [as 别名]
# 或者: from Math import sqrt [as 别名]
def guessing_game():
'''finish this. idea: want to calculate optimal cost C(10^12, sqrt{k}, sqrt{F_k}) where F_k is the k-th fibonacci number;
this means that the cost for overshooting the hidden number n in range(1,10^12) is much higher than the cost for undershooting
(or is it vice versa? check the rules.)... hence we should bias towards the low end by a factor given by a function of (k,F_k).
Idea: biased binary search?'''
result = 0.0
for k in range(1,30):
result += calculate_optimal_worst_case_cost(10**12, Math.sqrt(k), Math.sqrt((phi**k - ((-phi)**(-k))) / Math.sqrt(5)))
print result
示例2: __init__
# 需要导入模块: import Math [as 别名]
# 或者: from Math import sqrt [as 别名]
def __init__(self,id,s1,s2): #Arrête de s1 vers s2
self.id = id
self.sommet1 = s1
self.sommet2 = s2
self.length = Math.sqrt((s1.x-s2.x)**2+(s1.y-s2.y)**2)
self.pop = 0 #Combien d'unités parcourent cette arrête
self.owner = None #Qui possède ces unités