[Tutor] Use of sqrt() from math module

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


Matt Smith wrote:
> import sys, pygame, math
> 
> ...
> 
>     if ypos >= 384 and velocity > 0:
>         impactvel = sqrt(velocity ** 2 + (2 * gravity * (ypos - 384 * 
> 160)))
> 
> ...
> 
> 
> Traceback (most recent call last):
>   File "<stdin>", line 32, in <module>
> ValueError: math domain error

Apologies, the actual error I get when I run the code above is:

Traceback (most recent call last):
   File "<stdin>", line 31, in <module>
NameError: name 'sqrt' is not defined

The error I quoted first was when I tried to call 'math.sqrt(x)'

Matt



More information about the Tutor mailing list