Introduction to Functional Programming

Learn about the usage of functional programming in Python.

Functional programming

In functional programming, a problem is treated as an evaluation of one or more functions.

Therefore, a given problem is decomposed into a set of functions. These functions provide the main source of logic in the program.

Functions as first-class values

Python facilitates functional programming by treating functions as first-class data values. This means that:

  • Functions can be assigned to variables and then called using these variables.
  • Functions can be passed as arguments to another function and returned from a function.
  • Functions can be built at execution time, the way lists, tuples, etc. can be.

An example of assigning a function to a variable and calling the function using the variable is shown below:

Get hands-on with 1200+ tech skills courses.