Question: a Define a function do_math that checks If a number is odd or even, return the square of the number if it is odd and
a Define a function do_math that checks If a number is odd or even, return the square of the number if it is odd and the cube of the number if it is even. Create a list of the Integers 1 through 5, and use a for loop to apply the function to each element in the list, printing out the return value from the function. Your code here def do_math(x): sart** Ust - [1, 2, 3, 4, 51 for 1 in range (1, 5) print(list) # For testing your code, do not modify assert (do_math(4) --64) assert (do_math(5)-25) assert (len(list)=-5)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
