[Tutor] Use of sqrt() from math module
Matt Smith
matt at mattanddawn.orangehome.co.uk
Sat Dec 1 15:42:23 CET 2007
Hi,
I need to find the square root of a number in a program I am writing. I have
imported the 'math' module so I thought I could just call sqrt(x) but I get an
error message. Extact from my code and error message below.
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
This one has me stumped as the usage of the module looks straight forward from
the documentation. Thanks for looking.
Matt
More information about the Tutor
mailing list