Sum of powers
Returns the sum of the powers of all the numbers from start to end (both inclusive).
- Use
range()in combination with a list comprehension to create a list of elements in the desired range raised to the givenpower. - Use
sum()to add the values together. - Omit the second argument,
power, to use a default power of2. - Omit the third argument,
start, to use a default starting value of1.