<div class="gmail_quote">On Sun, Apr 18, 2010 at 10:21 AM, Aidas <span dir="ltr"><<a href="mailto:aidas@vineva.lt">aidas@vineva.lt</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello.<br>
In here <a href="http://mail.python.org/pipermail/tutor/2001-February/003385.html" target="_blank">http://mail.python.org/pipermail/tutor/2001-February/003385.html</a> You had written how to ger root in python. The way is: "from math import sqrtprint sqrt( 49 )".<br>
<br>
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 )"?<br>
<br>
P.S. Sorry about english-I'm lithuanian. :)<br>
<br></blockquote><div><br></div><div><div>>>> sqrt()</div><div>Traceback (most recent call last):</div><div> File "<stdin>", line 1, in <module></div><div>NameError: name 'sqrt' is not defined</div>
</div><div><br></div><div>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 defined.</div><div><br></div><div>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.</div>
<div><br></div><div>Then you can use it:</div><div><div>>>> from math import sqrt</div><div>>>> print sqrt(49)</div><div>7.0</div></div><div><br></div><div><br></div><div>HTH,</div><div>Wayne</div><div>
<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</blockquote></div><br>