本文整理匯總了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