On Fri, 26 Feb 2010 05:34:39 am Ricardo Aráoz wrote:
> So why would the coders of the math module go to the trouble of
> creating the pow function?
http://docs.python.org/library/math.html#math.pow
http://docs.python.org/library/functions.html#pow
The math module is mostly a thin wrapper around
i'm not an expert, but i have worked with "import math".
i believe if you use import math; it will make you capable of using
all kinds of math in python (sin,cos,sin^-1..)
i recommend you google "python math" or "python import math", and that
will take you to the library reference.
its he
On Fri, 26 Feb 2010 04:27:06 am Monte Milanuk wrote:
> So... pow(4,4) is equivalent to 4**4, which works on anything -
> integers, floats, etc., but math.pow(4,4) only works on floats... and
> in this case it converts or interprets (4,4) as (4.0,4.0), hence
> returning a float: 256.0. Is that about
Monte Milanuk, 25.02.2010 18:27:
> So... pow(4,4) is equivalent to 4**4, which works on anything - integers,
> floats, etc.
Correct, e.g.
>>> class Test(object):
... def __pow__(self, other, modulo=None):
... print("POW!")
... return 'tutu'
...
>>> pow(Test(), 4)
POW!
2010/2/25 Ricardo Aráoz
> Stefan Behnel wrote:
> So why would the coders of the math module go to the trouble of creating
> the pow function? Did they create a sum function and a subtract function?
> It seems to me the question has not been properly answered. When to use
> one, when to use the o
Stefan Behnel wrote:
> Monte Milanuk, 25.02.2010 16:47:
>
>> Is there a benefit (besides brevity) one way or the other between using:
>>
>> import math
>> ...
>> math.pow(x,y) # x raised to the power y
>>
>> vs.
>>
>> x**y
>>
>> ?
>>
>
> Did you try it?
>
> >>> import math
> >>> pr
Stefan Behnel wrote:
> Monte Milanuk, 25.02.2010 16:47:
>
>> Is there a benefit (besides brevity) one way or the other between using:
>>
>> import math
>> ...
>> math.pow(x,y) # x raised to the power y
>>
>> vs.
>>
>> x**y
>>
>> ?
>>
>
> You might also be interested in this:
>
> http://doc
Monte Milanuk, 25.02.2010 16:47:
> Is there a benefit (besides brevity) one way or the other between using:
>
> import math
> ...
> math.pow(x,y) # x raised to the power y
>
> vs.
>
> x**y
>
> ?
You might also be interested in this:
http://docs.python.org/reference/datamodel.html#emulating-n
Monte Milanuk, 25.02.2010 16:47:
> Is there a benefit (besides brevity) one way or the other between using:
>
> import math
> ...
> math.pow(x,y) # x raised to the power y
>
> vs.
>
> x**y
>
> ?
Did you try it?
>>> import math
>>> print(math.pow(4,4))
256.0
>>> 4**4
256
Is there a benefit (besides brevity) one way or the other between using:
import math
...
math.pow(x,y) # x raised to the power y
vs.
x**y
?
Thanks,
Monte
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://
10 matches
Mail list logo