[Tutor] Use of sqrt() from math module

Matt Smith matt at mattanddawn.orangehome.co.uk
Sat Dec 1 16:46:03 CET 2007


Michael H.Goldwasser wrote:
> After using "import math" you will need to use the qualified name
> math.sqrt(blah) to call the square root function.   That explains the
> NameError when trying to use the unqualified name, sqrt.
> 
> As to your first message, the ValueError that you are reporting with
> the usage math.sqrt is likely due to an attempt to take the square
> root of a negative number (presumably because your (ypos - 384 * 160)
> factor is negative.

Thanks Michael and Ziyad, it seems I just had my brackets in the wrong place 
leading to trying to square root a number less than 0.

Matt



More information about the Tutor mailing list