Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
improve formatting. Remove unnecessary parens.
Source Link
wjandrea

Here, the fastest method I would say is to just use math. To do this, you need to put this line at the top of your program: import math

import math

Then, this would be the syntax to check the square root: math.sqrt(num)

math.sqrt(num)

Another method with just regular arithmetic is to do num**(0.5)num**0.5, although I am pretty sure math.sqrtmath.sqrt does it faster anyway.

Here, the fastest method I would say is to just use math. To do this, you need to put this line at the top of your program: import math

Then, this would be the syntax to check the square root: math.sqrt(num)

Another method with just regular arithmetic is to do num**(0.5), although I am pretty sure math.sqrt does it faster anyway.

Here, the fastest method I would say is to just use math. To do this, you need to put this line at the top of your program:

import math

Then, this would be the syntax to check the square root:

math.sqrt(num)

Another method with just regular arithmetic is to do num**0.5, although I am pretty sure math.sqrt does it faster anyway.

Source Link
godchunguus

Here, the fastest method I would say is to just use math. To do this, you need to put this line at the top of your program: import math

Then, this would be the syntax to check the square root: math.sqrt(num)

Another method with just regular arithmetic is to do num**(0.5), although I am pretty sure math.sqrt does it faster anyway.

lang-py