[Tutor] sqrt?
bob gailer
bgailer at gmail.com
Sun Apr 25 21:52:10 CEST 2010
On 4/24/2010 11:00 PM, Kirk Z Bailey wrote:
> ok gang, My desktop runs 2.5, and for my college algebra I needed to
> do som quadratic equation work. This involves squareroots. So I fired
> uop the interactive idle and imported math. I then tried to play with
> sqrt.
>
> Nothing.
As Hugo pointed out - asking good questions is important. That includes
being really specific. "play" and "nothing" are not specific. We can
guess - we might even be right - but that is costly for all of us in time.
Python rarely gives "nothing".
You usually get some result (perhaps you don't agree with it) or some
error (traceback). Sometimes there is no visible result, as the case
with import.
So if I were willing to spend some time guessing I'd guess that you did
and got something like:
>>> import math
>>> sqrt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sqrt' is not defined
>>>
Please either confirm or alter the above. IOW show us what you entered
and what you got.
Did you read the Python Manual's explanation of import?
>
> Importing math does not import a sqrt function.
Not under that name, as a global variable. It did create a global name
math. Math has attributes, one of which is sqrt.
>
> Now riddle me this: if string.foo makes it do a function FOO on a string
Wow - so many assumptions, errors and generalities. Where would I even
begin?
> , whyfore and howcome does math.sqrt not do square roots on a simple
> number like 4???
O but it does, as others have pointed out
>>> math.sqrt(4)
2.0
>
> I am now officiciously pissed.
>
> Help?
>
--
Bob Gailer
919-636-4239
Chapel Hill NC
More information about the Tutor
mailing list