Simple square root calculator Very simple square root calculator. I am sure it's terrible and can be made much better.
I feel it's way too many lines.
import random

## ask user for a number to find sq root for
num1 = input(&quot;Please enter number for which we'll find sq root:\n&quot;)

## generate a random number and test it
randomNum1 = random.randint(1,9)
print(&quot;Random number is &quot; + str(randomNum1))

ranMul1 = 0

while True:
  if float(ranMul1) == float(num1):
    print(&quot;square root of &quot; + str(num1) + &quot; is &quot; + str(randomNum1))
    break
  else:
    randomNum1 = round((float(randomNum1) + (float(num1)/float(randomNum1))) / 2, 4)
    ranMul1 = round(randomNum1 * randomNum1,4)
    print(&quot;Trying number &quot; + str(randomNum1))
    continue
The great input from @hjpotter92 gets you 99% of the way there. The only additional comment I have is about this:
while num != random_num * random_num:

Exact comparison of floating-point numbers is problematic. You're going to want to pick some (very small) number, usually called epsilon, below which the error is insignificant and call that &quot;close enough&quot;.
Read https://docs.python.org/3/library/math.html#math.isclose for more details.