Lambda Functions

Learn how lambda functions work in Python by playing around with the examples provided in the lesson.

Lambda functions

Lambda functions sound like they are going to be something complicated, but they are actually very simple.

Let’s continue with the previous example, where we have a list of rectangles defined by a pair of values (width, height). For example, (3, 2) defines a rectangle that is 3 units wide by 2 units high. We wish to sort them by increasing area. To do this, we define the area function, as shown below.

Get hands-on with 1400+ tech skills courses.