Question: in python Write a function called list_powers . This function will take a list, and return a new list where each element is exponentiated to
in python
Write a function called list_powers . This function will take a list, and return a new list where each element is exponentiated to a specified power. Input(s): - collection - collection of numbers - power - int, default value: 2 Output(s): - power_list - list of numbers Procedure(s): - Initialize an empty list to be filled and returned - Loop through each element in the input collection - Take the value to the power specified in power - Append the result to the output list - Return the list of powers ] : ] : assert callable(list_powers) assert type ( list_powers ([1,2]))== list assert list_powers ((2,4))=[4,16]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
