Menu
Coddy logo textTech

With arguments

Lesson 3 of 9 in Coddy's Python Lambda Functions course.

Now let's see some examples of lambda functions with arguments,

cube = lambda x : x * x * x
print(cube(3))  # prints 27
print(cube(5))  # prints 125

Another example, (Using the one line format of if-else statement)

max_num = lambda a, b : a if(a > b) else b
print(max_num(5, 9))  # prints 9

You can add as many arguments as you want!

Notice the main usage of lambdas is short and simple operations.

challenge icon

Challenge

Easy

Create a lambda function that gets three variables as arguments and returns True if the arguments are equal, otherwise False, assign the lambda to is_equal variable.

If one of the arguments is None, ignore it!

Try it yourself

# Write code here

All lessons in Python Lambda Functions

2With built-in Function

filtermap