Question: Q2 Write a lambda expression and assign it to the variable oddcubed such that it cubes the value of its single argument if the argument
Q2 Write a lambda expression and assign it to the variable oddcubed such that it cubes the value of its single argument if the argument is odd, and doubles it if the argument if it is even Afterward, for example, expression oddcubed (5) should yield 125, while oddcubed (4) should yield 8. Hint: We need an expression to handle an if type condition. See the book discussion on the ternary if. # Solution cell 1 W YOUR CODE HERE raise Not ImplementedError() print(oddcubed (5)) print(oddcubed (4) assert oddcubed (5) - 125 assert oddcubed (0) assert oddcubed(-1) -1 assert oddcubed (2) - 4 assert oddcubed (-2) boh
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
