About 229,000 results
Open links in new tab
  1. How do I calculate square root in Python? - Stack Overflow

    Jan 20, 2022 · Arbitrary precision square root. This variation uses string manipulations to convert a string which represents a decimal floating-point number to an int, calls math.isqrt to do the …

  2. Is there a short-hand for nth root of x in Python?

    Any nth root is an exponentiation by 1/n, so to get the square root of 9, you use 9**(1/2) (or 9**0.5) to get the cube root, you use 9 ** (1/3) (which we can't write with a simpler fraction), …

  3. performance - Which is faster in Python: x**.5 or math.sqrt (x ...

    This is simply a question of how the underlying code actually works. What is the theory of how Python code works? I sent Guido van Rossum an email cause I really wanted to know the …

  4. How to perform square root without using math module?

    Jun 15, 2010 · x=float(input()) min1=0 max1=x for i in range(10): mid=(min1+max1)/2 #middle value res=mid**2 #finding the square of middle value if res==x: #if the middle value is square …

  5. python - finding prime number using the square root method

    Feb 5, 2019 · If this is python 3 it doesn't matter, but in python 2.x, range creates a list and iterates it and xrange creates a generator, so using xrange will be much faster. – Not_a_Golfer …

  6. Why does Python give the "wrong" answer for square root? What …

    This behavior is "normal" in Python 2.x, whereas in Python 3.x 1/2 evaluates to 0.5. If you want your Python 2.x code to behave like 3.x w.r.t. division write from __future__ import division - …

  7. How can I take the square root of -1 using python?

    The square root of -1 is not a real number, but rather an imaginary number. IEEE 754 does not have a way of representing imaginary numbers. numpy has support for complex numbers.

  8. math - Integer square root in python - Stack Overflow

    Mar 13, 2013 · Python's default math library has an integer square root function: math.isqrt(n) Return the integer square root of the nonnegative integer n. This is the floor of the exact …

  9. square root - Python sqrt limit for very large numbers ... - Stack …

    Jan 31, 2015 · Python handles ridiculously large integer numbers without problems. For floating point numbers, it uses standard (C) conventions, and limits itself to 64 bit precision. You …

  10. How to find cube root using Python? - Stack Overflow

    Jan 18, 2015 · This takes the cube root of x, rounds it to the nearest integer, raises to the third power, and finally checks whether the result equals x. The reason to take the absolute value is …