Functional Programming With Python

Learning PathSkills: Python, Functional Programming, Lambda Functions, Built-in Functions, Map, Filter, Reduce, Scope, Closures, Inner Functions, Decorators, Recursion

A smiling person with their hands crossed, looking at a machine that displays the names of the functions map, filter, and reduce

In this learning path, you’ll explore functional programming techniques in Python. Starting with lambda functions and built-ins like any() and all(), you’ll move on to map(), filter(), and functools.reduce(), and then learn about scope, closures, inner functions, and decorators. The path wraps up with recursion and recursive thinking.

Functional Programming With Python

Learning Path ⋅ 14 Resources

Introduction to Functional Programming

Get an overview of functional programming in Python and learn when and how to apply functional techniques in your code.

Title image for Using Functional Programming in Python (Functional Programming in Python: When and How to Use It)

Course

Using Functional Programming in Python

Boost your Python skills with a quick dive into functional programming: what it is, how Python supports it, and why it matters.

Lambda Functions and Built-ins

You’ve seen what functional programming looks like in Python. Now you’ll meet the tools it leans on, starting with lambda for small anonymous functions and moving through Python’s built-in functions, including any() and all(). These are the pieces you’ll combine in the sections that follow.

Title image for Using Python Lambda Functions (How to Use Python lambda Functions)

Course

Using Python Lambda Functions

Learn about Python lambda functions. You'll see how they compare with regular functions and how you can use them in accordance with best practices.

Title image for Python Lambda Functions (How to Use Python lambda Functions)

Interactive Quiz

Python Lambda Functions

Title image for Exploring Python's Built-in Functions (Python's Built-in Functions: A Complete Exploration)

Course

Exploring Python's Built-in Functions

Learn Python's built-in functions for math, data types, iterables, and I/O, and when to use each to write more Pythonic code.

Title image for Python any(): Powered Up Boolean Function (Python any(): Powered Up Boolean Function)

Course

Python any(): Powered Up Boolean Function

If you've ever wondered how to simplify complex conditionals by determining if at least one in a series of conditions is true, then look no further. This video course will teach you all about how to use any() in Python to do just that.

Title image for Python's all(): Check Your Iterables for Truthiness (Python's all(): Check Your Iterables for Truthiness)

Tutorial

Python's all(): Check Your Iterables for Truthiness

Learn how to use Python's all() function to check if all the items in an iterable are truthy. You'll also code various examples that showcase a few interesting use cases of all() and highlight how you can use this function in Python.

Functional Tools: map, filter, and reduce

Lambdas and built-ins gave you small throwaway functions and ready-made helpers. Next, you’ll put them to work with map(), filter(), and reduce(), the higher-order functions at the center of functional Python. Each one replaces a common loop pattern with a single call over an iterable.

Title image for Python's map() Function: Transforming Iterables (Python's map(): Processing Iterables Without a Loop)

Course

Python's map() Function: Transforming Iterables

Learn how Python's map() works and how to use it effectively in your programs. You'll also learn how to use list comprehension and generator expressions to replace map() in a Pythonic and efficient way.

Title image for Filtering Iterables With Python (Python's filter(): Extract Values From Iterables)

Course

Filtering Iterables With Python

Learn how Python's filter() works and how to use it effectively in your programs. You'll also learn how to use list comprehension and generator expressions to replace filter() and make your code more Pythonic.

Title image for Python's reduce(): From Functional to Pythonic Style (Python's reduce(): From Functional to Pythonic Style)

Tutorial

Python's reduce(): From Functional to Pythonic Style

Learn how Python's reduce() works and how to use it effectively in your programs. You'll also learn some more modern, efficient, and Pythonic ways to gently replace reduce() in your programs.

Scope, Closures, and Decorators

Passing functions around raises a question the last section left open, which is what names a function can actually see. You’ll start with the LEGB rule Python uses to resolve names, then build on it with inner functions, closures that carry state between calls, and decorators that wrap one function inside another.

Title image for The LEGB Rule & Understanding Python Scope (Python Scope & the LEGB Rule: Resolving Names in Your Code)

Course

The LEGB Rule & Understanding Python Scope

In this step-by-step video course, you'll learn what scopes are, how they work, and how to use them effectively to avoid name collisions in your code.

Title image for Python Inner Functions (Python Inner Functions)

Course

Python Inner Functions

Learn what inner functions are in Python, how to define them, and what their main use cases are.

Title image for Python Decorators 101 (Python Decorators)

Course

Python Decorators 101

In this course on Python decorators, you'll learn what they are and how to create and use them. Decorators provide a simple syntax for calling higher-order functions in Python. By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it.

Title image for Primer on Python Decorators (Python Decorators)

Interactive Quiz

Primer on Python Decorators

Recursion

Decorators showed you one function defined in terms of another. Recursion goes a step further, with a function defined in terms of itself. You’ll see how Python handles recursive calls and their limits, then practice framing problems recursively so the solution falls out of the definition.

Title image for Recursion in Python (Recursion in Python: An Introduction)

Course

Recursion in Python

A recursive function is one that calls itself. In this video course, you'll see what recursion is, how it works in Python, and under what circumstances you should use it.

Title image for Thinking Recursively With Python (Recursion in Python)

Course

Thinking Recursively With Python

Learn how to work with recursion in your Python programs by mastering concepts such as recursive functions and recursive data structures.

Test Your Knowledge

You’ve made it through the entire path! In the wrap-up quiz below, you’ll revisit the most important ideas about first-class functions, lambdas, map(), filter(), reduce(), closures, decorators, and recursion. Use it to spot any topics that still feel rusty before moving on.

Title image for Functional Programming With Python (A smiling person with their hands crossed, looking at a machine that displays the names of the functions map, filter, and reduce)

Interactive Quiz

Functional Programming With Python

Test your grasp of functional programming in Python: pure functions, lambdas, map, filter, reduce, closures, decorators, and recursion.

Congratulations on completing this learning path! You’ve learned functional programming techniques in Python, from lambda functions and built-ins to map(), filter(), and reduce(), then on through scope and the LEGB rule, closures, decorators, and recursion.

Continue your intermediate Python journey with the next learning path:

Learning Path

Generators and Generator Expressions

6 Resources ⋅ Skills: Python, Iterators, Iterables, Itertools, Asynchronous Iterations, Generators, Yield

You might also be interested in these related learning paths:

Got feedback on this learning path?

Looking for real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

« Browse All Learning Paths