Anonymous Function

Last Updated: 02th September 2025


An anonymous function is a function that is defined without a name.It is also known as a lambda function or lambda expression.

📝 Syntax:

lambda arguments: expression

Example 1.

add = lambda x, y: x + y
result = add(3, 5)
print(result)    # Output: 8

Example 2.

check = lambda x: "Even" if x % 2 == 0 else "Odd"
print(check(14))
print(check(17))

Example 3.

li = [lambda arg=x: arg * 10 for x in range(1, 5)]
for i in li:
    print(i())

💡 Quick Practice