Computer Science, asked by avinsmallo8169, 11 months ago

How do you make a higher order function in Python ?

Answers

Answered by anamkhurshid29
0

We can make higher order by joining them i.e adding logical gatess

Answered by letmeanswer12
0

Creating higher order function in Python

Explanation:

  • A function is called the Higher Order function because it includes other functions as a parameter or returns a function as an output, i.e. the functions working with another function are known as Higher Order Functions. The higher order function is also applicable to functions and methods which take functions as a parameter or result in returning a function.

The following example shows how to write a higher order function in Python:

  • def twice(function):
  • return lambda x: function(function(x))
  • def f(x):
  • return x + 2
  • g = twice(f)
  • print g(6)

Output −

  • 10

Similar questions