Hindi • Lesson 11

Higher Order Functions in Python, map, filter and reduce | Python in Hindi |#76

Higher Order Function:
A Function that that take other function as argument or return a function is called higher order functions.

There are numbers of built-in higher order functions like
map
filter
reduce
sort etc..

map() function in python
====================
The built-in function map() takes a function as a first argument and applies it to each of the elements of its
second argument, an iterable.
Syntax:
map(func, iterable,…)

returns a map object(which is an iterator)

==========PRACTICE QUESTIONS==========
1. Extract First Character of Each String.
GIVEN:
words = ['apple', 'banana', 'cherry']
Expected OUTPUT:
['a', 'b', 'c']

2. Concatenate Corresponding Elements from Two Lists.
GIVEN:
list1 = ['Hello', 'Good']
list2 = ['World', 'Morning']
Expected OUTPUT:
['Hello World', 'Good Morning']

3. Convert a List of Temperatures from Celsius to Fahrenheit.
GIVEN:
celsius = [0, 20, 37, 100]
Expected OUTPUT:
[32.0, 68.0, 98.6, 212.0]

4. Transpose a Matrix
GIVEN:
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
Expected OUTPUT:
[
[1, 4, 7],
[2, 5, 8],
[3, 6, 9]
]


#codewithdaneyal #python #pythoninhindi