[Tutor] Python root.
waynejwerner at gmail.com
Sun Apr 18 22:15:58 CEST 2010
On Sun, Apr 18, 2010 at 10:21 AM, Aidas <aidas at vineva.lt> wrote:
> In here http://mail.python.org/pipermail/tutor/2001-February/003385.htmlYou had written how to ger root in python. The way is: "from math import
> sqrtprint sqrt( 49 )".
> I noticed that if I write just "print sqrt(49)" I get nothing. So why I
> need to write "from math import sqrt" instead of write just "print sqrt( 49
> P.S. Sorry about english-I'm lithuanian. :)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sqrt' is not defined
That traceback tells you what the error is and where the error is. The
NameError is the specific type of error, and it tells you why - sqrt is not
In order to call a function its name needs to be defined. When you type '>>>
from math import sqrt' then you are importing the function (or name) sqrt
from the math module.
Then you can use it:
>>> from math import sqrt
>>> print sqrt(49)
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor