[Tutor] in-built square root function

Ole Jensen learning.python@dbmail.dk
Wed Feb 19 16:43:01 2003


This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C2D868.0B7D61C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

when experimenting alittle with pythons math functions I was puzzled =
concerning the results I get when trying to use the squareroot function =
(sqrt(x) according to the documentation found @ =
http://www.python.org/doc/current/lib/module-math.html)

my problem:

>>> import math
>>> sqrt(9)
Traceback (most recent call last):
  File "<pyshell#14>", line 1, in ?
    sqrt(9)
NameError: name 'sqrt' is not defined
>>>=20

If I have made a very stupid speeling mistake etc, Im sorry, but I can't =
 really see what Im doing wrong!

I succesfully used the power function:
>>> pow(3,2)
9
>>>=20

So Im just wondering what Im doing wrong...

for now though I'll just stick with the power of 0.5 when finding the =
sqrt
thx for any info youve got

Ol=E9
ole_jensen@dbmail.dk
------=_NextPart_000_000B_01C2D868.0B7D61C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>when experimenting alittle with pythons =
math=20
functions I was puzzled concerning the results I get when trying to use =
the=20
squareroot function (sqrt(x) according to the documentation found @ <A=20
href=3D"http://www.python.org/doc/current/lib/module-math.html">http://ww=
w.python.org/doc/current/lib/module-math.html</A>)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>my problem:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; import =
math<BR>&gt;&gt;&gt;=20
sqrt(9)<BR>Traceback (most recent call last):<BR>&nbsp; File=20
"&lt;pyshell#14&gt;", line 1, in ?<BR>&nbsp;&nbsp;&nbsp; =
sqrt(9)<BR>NameError:=20
name 'sqrt' is not defined<BR>&gt;&gt;&gt; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>If I have made a very stupid =
speeling&nbsp;mistake=20
etc, Im sorry, but I can't&nbsp; really see what Im doing =
wrong!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I succesfully used the power =
function:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; =
pow(3,2)<BR>9<BR>&gt;&gt;&gt;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So Im just wondering what Im doing=20
wrong...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>for now though I'll just stick with the =
power of=20
0.5 when finding the sqrt</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>thx for any info youve got</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ol=E9<BR><A=20
href=3D"mailto:ole_jensen@dbmail.dk">ole_jensen@dbmail.dk</A><A=20
href=3D"mailto:n@dbmail.dk"></A></FONT></DIV></BODY></HTML>

------=_NextPart_000_000B_01C2D868.0B7D61C0--