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

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Python Fundamentals

Lesson 11 of 55 · Python

Lambda Functions

Duration: 20 minutes

Lambda Functions\n\nLambda (anonymous) functions are handy for short, throw‑away functionality. The syntax is lambda args: expression.\n\npython\nsquare = lambda x: x * x\nprint(square(5)) # 25\n\n# Sorting a list of tuples by the second element\npeople = [(1, 'b'), (2, 'a'), (3, 'c')]\nsorted_people = sorted(people, key=lambda item: item[1])\nprint(sorted_people)\n\n\nBecause a lambda can only contain a single expression, they’re best used as callbacks for functions like sorted, map, or filter.\n

Previous: Arguments and Return ValuesNext: Scope and Namespace