Question: 07 Write a lambda expression and assign it to the variable evensquared such that it squares the value of its single argument if the argument
07 Write a lambda expression and assign it to the variable evensquared such that it squares the value of its single argument if the argument is even, and cubes the argument if it is odd. Afterward, for example, expression evensquared() should yield 125, while evensquared(4) should yield 16 Hint: We need an expression to handle an if type condition In Your CODE MORE raise Not Implementederror() In Testing cell print(even Squared (5) print(evensquared (4) In 1 Testing cell assert(evensquared(111) assert(evensquared (2) assert (evensquared(3127) assert (evensquared( 416) assert (evensquared())
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
