[Tutor] raising number to a power

Steven D'Aprano steve at pearwood.info
Thu Feb 25 19:57:00 CET 2010

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 right?

Pretty much, but the builtin pow also takes an optional third argument:

>>> pow(4, 4, 65)  # same as 4**4 % 65 only more efficient

By the way, are you aware that you can get help in the interactive 


Steven D'Aprano

More information about the Tutor mailing list