Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Lambda Functions | Python Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Python Fundamentals

Lesson 11 of 55

·Python

Lambda Functions

20 minutes

Course progress20%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Create small, unnamed functions with `lambda`.
  • Lambdas consist of arguments and a single expression.
  • Commonly used as callbacks for `sorted()`, `map()`, `filter()`, etc.

Lambda Functions

Lambda (anonymous) functions are handy for short, throw‑away functionality. The syntax is lambda args: expression.

square = lambda x: x * x
print(square(5))  # 25

# Sorting a list of tuples by the second element
people = [(1, 'b'), (2, 'a'), (3, 'c')]
sorted_people = sorted(people, key=lambda item: item[1])
print(sorted_people)

Because a lambda can only contain a single expression, they’re best used as callbacks for functions like sorted, map, or filter.

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Python FundamentalsBrowse activities
Previous lessonArguments and Return ValuesContinue to lesson 12Scope and NamespaceBack to Python Fundamentals curriculum