Python reduce() Function is a function that implements a mathematical technique called folding or reduction. reduce() is useful when you need to apply a function to an iterable and reduce it to a single cumulative value. Python’s reduce() is popular among developers with a functional programming background, but Python has more to offer.
The reduce(fun,seq) function is used to apply a particular function passed in its argument to all of the list elements mentioned in the sequence passed along. This function is defined in “functools” module.
reduce() function reduces sequence of elements into a single element by applying the specified function.
reduce() function present in functools module and hence we should write import statement.
|from functools import *
print(result) # 150
from functools import *
Python Tutorial – Learn Python
What is Python? What makes Python so Powerful?
Variables in Python – Constant, Global & Static Variables
Namespacing and Scopes in Python
TUPLE Data Structure in PYTHON
Differences between List and Tuple
DICTIONARY Data Structure in PYTHON
Database Programming in Python
What is Multithreading in Python?
Python Exception Handling Using try, except and finally statement
Lambda Function in PYTHON (Anonymous Function)