Error with math.sqrt
Chris Angelico
rosuav at gmail.com
Sat Jan 7 19:23:29 EST 2017
On Sun, Jan 8, 2017 at 11:15 AM, Jack Harvey <jackrharvey at hotmail.com> wrote:
> I'm starting out with Python 3.5. My current frustration is with:
>
>
>>>> math.sqrt(25)
> Traceback (most recent call last):
> File "<pyshell#0>", line 1, in <module>
> math.sqrt(25)
> NameError: name 'math' is not defined
>>>>
>
>
> Advice?
A lot of Python's features are in what's called the "standard library"
- a set of modules that you can call up with the 'import' statement.
In this case, all you need is to start with this line:
import math
Once you do that, everything in the math module (including math.sqrt)
should be available.
Enjoy!
ChrisA
More information about the Python-list
mailing list