Learn with Yasir
Share Your Feedback

Python Lambda Function Exercises - Practice Problems with Solutions


๐Ÿงช Coding Exercises

๐ŸŸข Beginner Exercises

  1. Calculate Rectangle Area
  2. Create a lambda function to calculate the area of a rectangle.

    Requirements

    No specific requirements for this exercise.

    Input
    4, 7
    
    Expected Output
    28
    

  3. Combine Strings
  4. Create a lambda function to concatenate two strings with a space.

    Requirements

    No specific requirements for this exercise.

    Input
    "Hello", "World"
    
    Expected Output
    "Hello World"
    

๐ŸŸก Intermediate Exercises

  1. Reverse a String
  2. Create a lambda function to reverse a string.

    Requirements

    No specific requirements for this exercise.

    Input
    "hello"
    
    Expected Output
    "olleh"
    

  3. Check Substring
  4. Create a lambda function that returns `True` if a substring exists in a string.

    Requirements

    No specific requirements for this exercise.

    Input
    "world", "hello world"
    
    Expected Output
    True
    

  5. Maximum of Two Numbers
  6. Create a lambda function to return the maximum of two numbers.

    Requirements

    No specific requirements for this exercise.

    Input
    8, 12
    
    Expected Output
    12
    

  7. Uppercase Conversion
  8. Create a lambda function to convert a string to uppercase.

    Requirements

    No specific requirements for this exercise.

    Input
    "lambda"
    
    Expected Output
    "LAMBDA"
    

  9. Check Palindrome
  10. Create a lambda function to check if a string is a palindrome.

    Requirements

    No specific requirements for this exercise.

    Input
    "madam"
    
    Expected Output
    True
    

๐Ÿ”ด Advanced Exercises

  1. Square List Elements (with `map`)
  2. Use a lambda with `map` to square each element in a list.

    Requirements

    No specific requirements for this exercise.

    Input
    [1, 2, 3, 4]
    
    Expected Output
    [1, 4, 9, 16]
    

  3. Filter Even Numbers (with `filter`)
  4. Use a lambda with `filter` to extract even numbers from a list.

    Requirements

    No specific requirements for this exercise.

    Input
    [1, 2, 3, 4, 5, 6]
    
    Expected Output
    [2, 4, 6]
    


๐Ÿง  Practice & Progress

Explore More Topics

Python Fundamentals

Flow Control Statements


Python Functions


Fundamentals more ...




๐Ÿง  Python Advanced

Object-Oriented Programming in Python (OOP)

More...

๐Ÿง  Modules