+ 3

Sqrt?

what would be the python code of sqrt?

29th Dec 2016, 10:04 AM
Milan Zanden
Milan Zanden - avatar
5 Answers
+ 5
number**(1/2)
29th Dec 2016, 10:09 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
thnxx
29th Dec 2016, 10:10 AM
Milan Zanden
Milan Zanden - avatar
+ 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
29th Dec 2016, 10:11 AM
Mahir Asef Kabir
Mahir Asef Kabir - avatar
+ 2
def sqrt(n): x,y = float(n),1. 0 while x > y: x = (x + y) / 2.0 y = n / x return x
1st Jan 2017, 6:39 AM
Suvaditya
Suvaditya - avatar