About 32,800 results
Open links in new tab
  1. math - Integer square root in python - Stack Overflow

    Mar 13, 2013 · Newton's method works perfectly well on integers: x = n. y = (x + 1) // 2. while y < x: x = y. y = (x + n // x) // 2. return x. This returns the largest integer x for which x * x does not exceed n. If you want to check if the result is exactly the square root, simply perform the multiplication to check if n is a perfect square.

  2. How do I calculate square root in Python? - Stack Overflow

    Jan 20, 2022 · It takes any type that can be converted to float (which includes int) and returns a float. The power operator (**) or the built-in pow () function can also be used to calculate a square root. Mathematically speaking, the square root of a equals a to the power of 1/2.

  3. Find Square Root Of Given Number - Python - GeeksforGeeks

    Feb 24, 2025 · Given an integer X, find its square root. If X is not a perfect square, then return floor (√x). For example, if X = 11, the output should be 3, as it is the largest integer less than or equal to the square root of 11. We can also find the floor of the square root using Python’s built-in exponentiation operator (**) and then integer conversion.

  4. Python | math.isqrt() method - GeeksforGeeks

    Apr 25, 2025 · math.isqrt () method in Python is used to get the integer square root of the given non-negative integer value n. This method returns the floor value of the exact square root of n or equivalently the greatest integer a such that a 2 <= n.

  5. Python math.sqrt () Method - W3Schools

    The math.sqrt() method returns the square root of a number. Note: The number must be greater than or equal to 0. Required. A number to find the square root of. If the number is less than 0, it returns a ValueError. If the value is not a number, it returns a TypeError. Math Methods. Track your progress - it's free!

  6. The Python Square Root Function

    Python’s sqrt() function calculates square roots using Python’s math.sqrt() for quick and accurate results in your programs. math.sqrt() calculates the square root of positive numbers and zero but raises an error for negative inputs.

  7. 4 Methods to Calculate Square Root in Python - AskPython

    Jul 6, 2021 · In this tutorial, we have learned the different ways to calculate the square root of numbers in Python. We have also learned how to use Python functions like math.sqrt(), math.pow(), and numpy.sqrt().

  8. Python math.sqrt () function | Find Square Root in Python

    Feb 14, 2025 · math.sqrt () returns the square root of a number. It is an inbuilt function in the Python programming language, provided by the math module. In this article, we will learn about how to find the square root using this function. Example:

  9. Python Square Root: How to Calculate a Square Root in Python

    Sep 4, 2021 · Learn how to use Python to calculate the square root of any number, with and without the math library, and to calculate integer square root.

  10. Python Find Square Root of Number – PYnative

    Mar 27, 2025 · Learn different ways to calculate the square root in Python, including using the math module and the exponentiation operator. Get clear code programs.

Refresh