If you want to do it the way the calculator actually does it, use the Babylonian technique. It is explained here and here.
Suppose you want to calculate the square root of 2:
a=2
a1 = (a/2)+1
b1 = a/a1
aminus1 = a1
bminus1 = b1
while (aminus1-bminus1 > 0):
an = 0.5 * (aminus1 + bminus1)
bn = a / an
aminus1 = an
bminus1 = bn
print(an,bn,an-bn)