Functional Programming With Python
Learning Path ⋅ Skills: Python, Functional Programming, Lambda Functions, Built-in Functions, Map, Filter, Reduce, Scope, Closures, Inner Functions, Decorators, Recursion
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.
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.
Interactive Quiz
Functional Programming in Python: When and How to Use It
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.
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.
Interactive Quiz
Python Lambda Functions
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.
Interactive Quiz
Python Built-in Functions: A Complete Guide
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.
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.
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.
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.
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.
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.
Interactive Quiz
Python Scope and the LEGB Rule: Resolving Names in Your Code
Course
Python Inner Functions
Learn what inner functions are in Python, how to define them, and what their main use cases are.
Interactive Quiz
Python Inner Functions: What Are They Good For?
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.
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.
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.
Interactive Quiz
Recursion in Python: An Introduction
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.
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!