py to newton's method for square root