

>>> def powersum(power, *args):
... '''Return the sum of each argument raised to specified power.''' ... total = 0
... for i in args:
... total += pow(i, power)
... return total
...
>>> powersum(2, 3, 4)
25
Due to the * prefix on theargs variable, all extra arguments passed to the function are stored inargs as a tuple. If a** prefix had been used instead, the extra parameters would be considered to be key/ value pairs of a dictionary.