Re: [Tutor] raising number to a power

2010-02-25 Thread Steven D'Aprano
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

Re: [Tutor] raising number to a power

2010-02-25 Thread salaiman alrayes
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

Re: [Tutor] raising number to a power

2010-02-25 Thread Steven D'Aprano
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

Re: [Tutor] raising number to a power

2010-02-25 Thread Stefan Behnel
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!

Re: [Tutor] raising number to a power

2010-02-25 Thread Wayne Werner
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

Re: [Tutor] raising number to a power

2010-02-25 Thread Ricardo Aráoz
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

Re: [Tutor] raising number to a power

2010-02-25 Thread Ricardo Aráoz
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

Re: [Tutor] raising number to a power

2010-02-25 Thread Stefan Behnel
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

Re: [Tutor] raising number to a power

2010-02-25 Thread Stefan Behnel
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

[Tutor] raising number to a power

2010-02-25 Thread Monte Milanuk
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://