Skip to content

functional programming

Functional programming (FP) is a programming paradigm that emphasizes pure functions, immutable data, and function composition.

In Python, functional programming usually means writing functions that avoid changing global state and rely solely on their inputs and return values.

Although Python isn’t purely functional, you can still follow many functional principles using higher-order functions, lambda expressions, and built-in tools like map(), filter() and functools.reduce().

Key Concepts

  • Pure Functions: Return the same result given the same inputs, without side effects.
  • Immutability: Data doesn’t change in place; each operation creates new data.
  • Higher-Order Functions: Functions that take other functions as arguments or return them as results.

Example in Python

Python
>>> from functools import reduce

>>> numbers = [1, 2, 3, 4, 5]
>>> doubled = map(lambda x: x * 2, numbers)
>>> filtered = filter(lambda x: x % 2 == 0, doubled)
>>> summed = reduce(lambda acc, x: acc + x, filtered, 0)

>>> print(summed)
30

Real-world usage often involves processing large datasets or composing pipelines of small, reusable functions, making your code easier to test and maintain.

Learning Path

Functional Programming With Python

Explore functional programming in Python. Learn lambda functions, map(), filter(), reduce(), closures, decorators, and recursion.

intermediate python

For additional information on related topics, take a look at the following resources:


By Dan Bader • Updated Feb. 9, 2026