Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

What Is a Lambda Function?

For the rest of this course, you’ll mostly see the term lambda function. The following terms may be used interchangeably depending on the programming language type and culture:

  • Anonymous functions
  • Lambda functions
  • Lambda expressions
  • Lambda abstractions
  • Lambda form
  • Function literals

Taken literally, an anonymous function is a function without a name. In Python, an anonymous function is created with the lambda keyword. More loosely, it may or not be assigned a name.

00:00 What is a lambda function?

00:05 A lambda function is a simple, short, throwaway function which is designed to be created inline in code. They’re also known as lambda expressions, anonymous functions, lambda abstractions, lambda form, or function literals.

00:24 But they’re most commonly known as lambda functions or lambda expressions in the Python world. Let’s compare a standard function with a lambda function. Here you can see the definition of a simple function which takes in three numbers and returns the result of those three numbers added together. In comparison, here is the lambda form of that function.

00:48 You can see it starts with the keyword lambda, has the three input variables x, y, and z before a colon (:).

00:55 After the : is what is returned by the function. While that simple expression is repeated here, you can see some other forms onscreen which involve more calculation than mere addition.

01:10 Now you’re going to see a comparison between standard and lambda functions, with standard functions on the left and lambda functions on the right.

01:19 Generally, standard functions will be used many times in your code, whereas a lambda function is intended for single use inline in another function. Standard functions often involve multiple lines of code, and lambda functions will be defined in a single line.

01:36 Standard functions are typically named, whereas lambda functions can be named or anonymous. Standard functions will take none or more inputs and so will lambda functions, but standard functions can return none or more returned values, whereas a lambda function will return at least one value.

Become a Member to join the conversation.