Home › coding › python › py lambda

Py Lambda — Free Python Tutorial

Learn Py Lambda in Python with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

✓ 100% Free ✓ No Login Needed ✓ NCERT / CBSE Aligned ✓ Download as PDF

TL;DR: Learn Py Lambda in Python with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated Jul 14, 2026

🤖 Stuck on any question? Ask Syllab's free AI Tutor for a step-by-step explanation — instant, unlimited, no login.

Py Lambda in Python

A lambda function is a small, anonymous (nameless) function defined in a single line. It's useful when you need a simple function for a short time — especially as an argument to other functions.

Syntax: lambda arguments: expression. A lambda can take multiple arguments but has only one expression (which is automatically returned). It cannot contain if/else blocks (unless as a ternary expression) or loops.

Lambda is most commonly used with: sorted() for custom sort keys, map() to apply a function to every item, filter() to select items meeting a condition. These are called "higher-order functions".

Py Lambda — Syntax

# Regular function vs lambda:
def square(x): return x**2
square_lambda = lambda x: x**2

# Multi-argument lambda:
add = lambda x, y: x + y

# Lambda as sort key:
sorted(students, key=lambda s: s['marks'])

Learn Py Lambda step by step with Syllab's free interactive Python tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full Python course →

Explore:

  • Syllabus
  • Practice
  • Mock Tests
  • NCERT Solutions
  • Coding
  • GK Quiz
  • Career Predictor
  • AI Tutor
  • Live Quiz
  • Doubt Solver
  • Microlearning
  • Free Alternatives
  • Kids Zone
  • Study Room
  • Calculators
  • Worksheets

Syllab.in — Free learning for Indian students, Class 1–12