
>>> 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.
Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.
Popular searches:
Join 2 million readers and get unlimited free ebooks