[Tutor] in-built square root function

Timothy M. Brauch tbrauch@mindless.com
Wed Feb 19 16:52:02 2003


You made a mistake, but it is a very important error to get corrected when
using import.  Look at this...

>>> import math
>>> sqrt(9)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'sqrt' is not defined
>>> math.sqrt(9)
3.0
>>>

Now look at this one...
>>> from math import *
>>> math.sqrt(9)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'math' is not defined
>>> sqrt(9)
3.0
>>>

See if you can figure out what is going on.

 - Tim