[Tutor] raising number to a power

salaiman alrayes salrayes2 at gmail.com
Thu Feb 25 20:00:10 CET 2010


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 helpful.
On Feb 25, 2010, at 1:35 PM, Ricardo Aráoz wrote:

> 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
>>     >>> print(math.pow(4,4))
>>     256.0
>>     >>> 4**4
>>     256
>>     >>> 4.0**4
>>     256.0
>>
>> Stefan
>>
> Yes, I tried it.
> Now, is there a benefit (besides brevity) one way or the other?
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list