Can't get sqrt() func to work

sam samthecat172 at comcast.net
Thu Jan 16 21:55:43 EST 2003


Jack,

    Try

>>>import math
>>>math.sqrt(25)
5.0



"deadair88" <deadair at swirvemail.com> wrote in message
news:fda1f7e0.0301161844.5c236733 at posting.google.com...
> Ok...I'm certanly not the Python expert but I do use it for many small
> tasks. I'm writing a small program for testing the primality of a
> number and need to call the sqrt() function as defined in the C
> standard or the python module math or cmath both of which should be
> built in. When I call the func sqrt(x) I get an error that looks
> something like this:
>
> >>>Traceback (most recent call last):
> >>>  File "<pyshell#1>", line 1, in ?
> >>>    sqrt(25)
> >>>NameError: name 'sqrt' is not defined
>
> I've tried calling from IDLE and the command prompt both to avail.
> I've tried running it from a module file with no luck. I've imported
> both math and cmath and still I can't get that darn function to work.
> What is the problem here?
>
> Thanks
> Jack D T






More information about the Python-list mailing list