Learn with Yasir
Share Your Feedback

Python Lambda Fill-in-the-Blank Exercises | Hands-On Practice Problems


Test your Python skills with interactive fill-in-the-blank lambda function exercises. Practice lambda syntax, filtering, mapping, and real-world coding scenarios.

🔍 Fill in the Blanks

🟢 Beginner

  1. In Python, a lambda function is created using the ________ keyword.
  2. Answer

    lambda

    Lambda functions in Python are defined using the `lambda` keyword followed by arguments and an expression.


  3. A lambda function in Python can have any number of ________, but can only have one ________.
  4. Answer

    arguments, expression

    Lambda functions can take any number of arguments, but they must consist of exactly one expression.


  5. The syntax of a lambda function is ________.
  6. Answer

    lambda arguments: expression

    The syntax for a lambda function is `lambda` followed by the arguments, a colon, and then the expression.


  7. The following lambda function is used to add 10 to a number: `add_ten = ________ x: x + 10`.
  8. Answer

    lambda

    This is a lambda function definition that adds 10 to the argument `x`.


  9. To multiply two numbers using a lambda function, the correct syntax would be `mul = ________ a, b: a * b`.
  10. Answer

    lambda

    This lambda function takes two arguments, `a` and `b`, and returns their product.


  11. The lambda function `is_even = ________ x: x % 2 == 0` checks if a number is ________.
  12. Answer

    lambda, even

    This lambda function checks if the number `x` is divisible by 2 (i.e., even).


  13. Lambda functions are often used when you need a ________ function without the need to formally define one.
  14. Answer

    small

    Lambda functions are typically used for small, one-off functions that are not reused elsewhere in the code.


  15. A lambda function in Python can return a value without using the ________ keyword.
  16. Answer

    return

    Unlike regular functions, lambda functions don't need the `return` keyword to return a result. The expression itself is the return value.


  17. The syntax of a lambda function requires a ________ after the `lambda` keyword.
  18. Answer

    list of arguments

    After the `lambda` keyword, you list the arguments for the function, followed by a colon and the expression.


🟡 Intermediate

  1. A lambda function is often used as an argument to a ________ function.
  2. Answer

    higher-order

    Lambda functions are often passed as arguments to higher-order functions, which are functions that take another function as an argument.


  3. In Python, lambda functions can be used with ________ functions like `map()`, `filter()`, and `reduce()`.
  4. Answer

    higher-order

    Higher-order functions take another function as an argument, and lambda functions are often used in such scenarios.


🔴 Advanced

  1. In the example `(lambda x, y : x + y)(6,8)`, the lambda function is defined and then immediately ________ with two arguments.
  2. Answer

    called

    This demonstrates an Immediately Invoked Function Expression (IIFE) where the lambda function is defined and called right away with the arguments `6` and `8`.




📚 Related Resources


🧠 Practice & Progress

Explore More Topics

Python Fundamentals

Flow Control Statements


Python Functions


Fundamentals more ...




🧠 Python Advanced

Object-Oriented Programming in Python (OOP)

More...

🧠 Modules