[Tutor] i need help on builtin function math

wilson edgar babyboy@oninet.pt
Thu, 29 Mar 2001 04:26:50 -0800


This is a multi-part message in MIME format.

------=_NextPart_000_0024_01C0B808.79930020
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

why don't you try this:

>>> import math
>>> a =3D 0
>>> b =3D math.sqrt(a)
>>> print b
0.0
>>>=20

or if just want to use the sqrt function:

>>> from math import sqrt
>>> a =3D 0
>>> b =3D sqrt(a)
>>> print b
0.0

the pow function is part of the builtin functions.
it would be a good idea for you to read about the namespaces

HTH

wilson edgar
  ----- Original Message -----=20
  From: Marcus Konermann=20
  To: tutor@python.org=20
  Sent: Wednesday, March 28, 2001 3:29 PM
  Subject: [Tutor] i need help on builtin function math


  hello !=20
  i want to use the sqrt() function of the builtin funtion math in that =
kind:=20

  import math=20
  ...=20
  a=3D0=20
  a=3Dsqrt(whatever)=20

  and than a NameError: sqrt occured and i don=B4t know why ? Is it =
depending on the OS (i use Windows98 and the pywin editor). Other =
functions, like pow(), from the math module are working.=20
  Can anyone help me with my problem ?=20

  thank=B4s a lot=20
  greetings=20
  Marcus=20


------=_NextPart_000_0024_01C0B808.79930020
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 content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>why don't you try this:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; import =
math<BR>&gt;&gt;&gt; a =3D=20
0<BR>&gt;&gt;&gt; b =3D math.sqrt(a)<BR>&gt;&gt;&gt; print=20
b<BR>0.0<BR>&gt;&gt;&gt; </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>or if just want to use the sqrt=20
function:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; from math import =
sqrt<BR>&gt;&gt;&gt;=20
a =3D 0<BR>&gt;&gt;&gt; b =3D sqrt(a)<BR>&gt;&gt;&gt; print =
b<BR>0.0</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>the pow function is part of the builtin =

functions.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>it would be a good idea for you to read =
about the=20
namespaces</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>HTH</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>wilson edgar</FONT></DIV></FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A href=3D"mailto:m_konermann@gmx.de" =
title=3Dm_konermann@gmx.de>Marcus=20
  Konermann</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
href=3D"mailto:tutor@python.org"=20
  title=3Dtutor@python.org>tutor@python.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Wednesday, March 28, 2001 =
3:29=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] i need help on =
builtin=20
  function math</DIV>
  <DIV><BR></DIV>hello !=20
  <P>i want to use the sqrt() function of the builtin funtion math in =
that kind:=20

  <P><I>import math</I> <BR><I>...</I> <BR><I>a=3D0</I>=20
  <BR><I>a=3Dsqrt(whatever)</I>=20
  <P>and than a <B>NameError: sqrt</B> occured and i don=B4t know why ? =
Is it=20
  depending on the OS (i use Windows98 and the pywin editor). Other =
functions,=20
  like pow(), from the math module are working. <BR>Can anyone help me =
with my=20
  problem ?=20
  <P>thank=B4s a lot <BR>greetings <BR>Marcus =
</P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0024_01C0B808.79930020--