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

Veröffentlicht am: 07 September 2024
auf dem Kanal: Code With Daneyal
266
8

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


Auf dieser Seite können Sie das Online-Video Higher Order Functions in Python, map, filter and reduce | Python in Hindi |#76 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Code With Daneyal 07 September 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 266 Mal angesehen und es wurde von 8 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!