#43 Python Tutorial for Beginners | Filter Map Reduce

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

For More Queries WhatsApp or Call on : +919008963671

In this lecture we will learn:
- Filter Map and Reduce in Python
- Use of filter(), map() and reduce() functions
- How lambda function can be used with filter map and reduce
- Syntax of Filter, Map and reduce function
- Difference between filter(), map() and reduce() functions

#1
- Lambda function can be used with these three functions:
1. filter()
2. map()
3. reduce()

#2
- filter() function will take a list and do filtering and give values.
- filter() takes a sequence and also returns a sequence.
- filter() function takes two arguments: function and iterable.
filter(func, iterable)
- We have to give the definition of a function that we have passed as a condition in an argument.
- The defined function should return a value of either True or False based on the condition.
- Then, filter() will take the value that is returned by the defined function and does perform filtering based on this value.
- In the defined function, we need only two things i.e, a variable and an expression. So, we can also use the lambda function instead of using the normal function to define the condition for a filter.
-Lambda reduces the number of lines of code and makes it more precise.
- Filter() simply returns the iterable passed to it.

#3
- map() function is used when we want to change the value of every element of a list.
- map() function also takes two arguments i.e., a function and an iterable.
map(func, *iterables)
- To get the result as a list, the built-in list() function can be called on the map object.
- We have to define a function that we have passed as a condition in an argument.
- The defined function should return any value.
- The lambda function can also be used in an argument as a function instead of defining the normal function for the logic.
- map() function returns a list. The function returns a map object which is a generator object.

#4
- reduce() function is used to reduce the number of values from a list.
- reduce() function belongs to a module known as functools.
- We have to import the module functools from the library to use the reduce function.
- reduce() also take two arguments i.e., a function and a sequence.
reduce(func, iterable[, initial])
- We have to give the definition of a function that we have passed as a condition in an argument.
- The lambda function can also be used in an argument as a function instead of defining the normal function for the logic.

Python Tutorial to learn Python programming with examples

Editing Monitors :

Subscribe to our other channel:
Telusko Hindi :

Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
Рекомендации по теме
Комментарии
Автор

Know what is the difference between filter, reduce and map:

map: Takes a function f, and a list L1, and returns a list L2 obtained by applying f to every element of L1. Say f is a function that takes x and returns 2x. Then, map(f, [1, 2, 3, 4]) returns [2, 4, 6, 8].

reduce: Takes a binary operator f, a list L and a seed value (or identity element). It returns the seed value if the list is empty. Otherwise, it applies the binary operator f to the seed and first element of L, then applies f to the result of this and the 2nd element of L, and so on till L is exhausted. The result is returned. This can be seen as a generalization of factorial function.

filter: Takes a boolean function f and a list L1. It applies the function to each element of L1, and list of those elements that give true is returned.
#insmot

NitinJainNoida
Автор

Finally found a cool programmeer who teaches these concepts in best possible way❤❤😇 Thanks navin sir

vikrantthakur
Автор

oh god! you are simply answering all the questions that pop my head. thank you navin. you have no idea what a great part you are holding in my life. because of you, im fearless and ready to learn programming. thank you for saving my life.

hemajeyalakshmi
Автор

the form of steps u choose while teaching is unique and more understandable as compared to other lecturers thank u sir great explanation☺️

sunilmaurya
Автор

this is one of the best python tutorial series for begineers


and the main part is it is free thank you sir

hrutikdhumal
Автор

This is so amazing! I learnt a whole lot about not just lambda from this video, but also these three other useful (albeit advances) functions! Thank you so much!

RaiyanAlphaRanger
Автор

Sir, you have made boring topics interesting for us..i love your teaching method..Great job!!

muskaan
Автор

Seriously your Python videos are amazing.
kudos to you

mohittrivedi
Автор

Sir...your teachings are awesome and you are a blessing to a lot of new programmers

rohithjohn
Автор

Than you sir, after working out this problem myself in laptop, this become simple now... You are a greater teacher and thanks for making me to sit here till above 40 video series. Everyday waking up with your videos make my day very active.... Thank you!

PrasannaKumar-zxgr
Автор

"that's what programmers do, making things cool" and how cool he looks with that action ;)

swarnimasingh
Автор

I saw you video after 2 months and editing level is whole different level. I got so much inspiration from you. thank you sir for making this video!!

pareshdandane
Автор

You are a teacher of note ... not only a coder ... Thanks for the effort. If I can do anything to help you expand ( other than liking or subscribing ), let me know.

deepwell
Автор

Many many thanks Navin for clearing the concept of Map Reduce. You are a gem. Super likes

vkrsoft
Автор

After a long time, I finally understood the concept of Lambda, Reduce, Map function. Great video and well explained. Thank you so much sir. Now eager to learn more and more every day through your videos. Thank you so much, keep up the great work.

asishraz
Автор

Lambda is my new crush, 😍😍❤️❤️
I love lambda

nehaaadarsh
Автор

such a headache of lambda syntax clarified so simply. Thankx.

nyxkshz
Автор

Navin sir can u make more videos and more concepts as soon as possible because we are understand very easy with ur explaination

NOTE : TRY TO MAKE SOME PROJECTS AND SOFTWARE USING THIS CONCEPTS

VikranthA
Автор

Your smart explanation helps me to get out of my fear in learning python😍😍😍

swethagopu
Автор

i was married to java and its version 8 features; after watching this i am planning to cheat in my relationship

divyeshkumarbalar