+3

# How can we calculate square root without using any built-in function in python?

There is already a function in module "math" of python called "sqrt()". But if I want to calculate the square of a number without using the "sqrt()", how can I do that? Is there any formula or any method for it?

4/5/2020 11:40:35 AM

Jojo

+5

there are two more ways currently I can refer(without using sqrt()) x = int(input()) import math print(pow(x, 0.5)) or, print(x**0.5)

+5

A very god question tho

+2

You can for instance say; root = Number**2. but why don't you want to use math.sqrt or one-half power? I see two main reasons to avoid that: when you need more precision than the rest significant digits that math.sqrt and one-half power provide, or you are working with large integers and you want an exact answer for the integer part of the square root.

+1

I can only assume that this is a homework question, otherwise why would you not use the built in function of the language? A quick search for "square root algorithm" gave "About 69,000,000 results (0.50 seconds) " https://en.wikipedia.org/wiki/Methods_of_computing_square_roots

+1

No, it isn't a homework question, a thought just passed through my mind and I couldn't find the anwer to it myself, even though it was easy😅

0

https://code.sololearn.com/c4DRJH1LnRHO/?ref=app

0

https://www.geeksforgeeks.org/square-root-of-an-integer/ Check that out.

0

x**0.5

0

# square root a=int(input("enter no.")) b=a**0.5 print(b)