Using "import math".

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Using "import math".

Steve Burrus
I need some help/assistance with using the python "import math" function. Like I am trying to do a = math.sqrt(1000)
                  a.sqrt
but it fails. what am I doing wrong? Thanx for anyone's help.



Reply | Threaded
Open this post in threaded view
|

Using "import math".

Cameron Simpson
On 06Jun2015 15:03, Steve Burrus <steveburrus28 at gmail.com> wrote:
>I need some help/assistance with using the python "import math" function. Like I am trying to do a = math.sqrt(1000)
>                  a.sqrt
>but it fails. what am I doing wrong? Thanx for anyone's help.

Please post a tiny but complete example piece of code showing the problem so
that others can run it. Please also post the error message; if it is a stack
trace, include the full stack trace.

Thanks,
Cameron Simpson <cs at zip.com.au>

[The Press] had tried to contact usenet but that no one had been available
for comment.  That's odd, I thought, if there's one thing you can say about
usenet, its that there's usually someone available for comment.
        - Paul Taylor

Reply | Threaded
Open this post in threaded view
|

Using "import math".

MRAB-2
In reply to this post by Steve Burrus
On 2015-06-06 23:03, Steve Burrus wrote:
> I need some help/assistance with using the python "import math" function. Like I am trying to do a = math.sqrt(1000)
>                    a.sqrt
> but it fails. what am I doing wrong? Thanx for anyone's help.
>
In what way does it fail?

If it printed an error message, copy and paste it in its entirety.


Reply | Threaded
Open this post in threaded view
|

Using "import math".

Chris Warrick
In reply to this post by Steve Burrus
On 7 Jun 2015 00:06, "Steve Burrus" <steveburrus28 at gmail.com> wrote:
>
> I need some help/assistance with using the python "import math" function.
Like I am trying to do a = math.sqrt(1000)
>                   a.sqrt
> but it fails. what am I doing wrong? Thanx for anyone's help.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Here's what your code did:

import math  # make the math module accessible
a = math.sqrt(1000)  # set `a` to the square root of 1000 (?31.62...)
a.sqrt  # get a reference to the sqrt method/attribute of a float, which
does not exist; moreover you are not calling the method/discarding the
value so it would be useless anyways

--
Chris Warrick <https://chriswarrick.com>
Sent from my Galaxy S3.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150607/b0247b69/attachment.html>