"Aidas" <ai...@vineva.lt> wrote
You had written how to ger root in python. The way is:
from math import sqrt
print 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"
Others have explained that you need to import the name sqrt from
the math module because sqrt is not defined as a "built-in" Python
function. But you can achieve the same thing using the pow() function,
which is built in - pow(49,0.5) - or the exponentiation operator - 49 ** 0.5
without using import...
You can read more about import and modules in the "Modules and
Functions" topic of my tutorial and more detail still in the "Whats in a name?"
topic.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor