+ 3
Sqrt?
what would be the python code of sqrt?
5 Antworten
+ 5
number**(1/2)
+ 3
thnxx
+ 2
You need to import math module. And then call math.sqrt. For example:
Code:
import math
x = math.sqrt(9)
print(x)
The above code prints 3.0 which is the square root of 9
+ 2
def sqrt(n):
x,y = float(n),1. 0
while x > y:
x = (x + y) / 2.0
y = n / x
return x