How would you define a variable that can store a lambda function calculating the square of a number in Python?

  • def square_lambda(x): return x * x
  • let square_lambda = (x) => x * x;
  • square_lambda = lambda x: x * x
  • var square_lambda = function(x) { return x * x; }

In Python, you can define a variable to store a lambda function using the lambda keyword, as shown in option 1. This creates a function that takes an argument x and returns its square.

Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *