functional programming (FP)
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
>>> 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.
Related Resources
Tutorial
Functional Programming in Python: When and How to Use It
See how Python supports functional programming, what the paradigm actually is, and where it fits in the code you write day to day.
For additional information on related topics, take a look at the following resources:
- Using Functional Programming in Python (Course)
- Python's reduce(): From Functional to Pythonic Style (Tutorial)
- Functional Programming With Python (Learning Path)
- Exploring Functional Programming in Python With Bruce Eckel (Podcast)
- From Python's Functional Primitives to Parallelism (Course)
- Functional Programming in Python: When and How to Use It (Quiz)
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Dan Bader • Updated Oct. 13, 2026