How To Use 'reduce()' In Python Tutorial (Functools)

preview_player
Показать описание
In this video we will be learning how we can use reduce() from functools in Python!

▶ Become job-ready with Python:

▶ Follow me on Instagram:
Рекомендации по теме
Комментарии
Автор

Amazing video👏 I love map() filter() and reduce(), I use them every time I see an opportunity.

dk-wwkp
Автор

I like to add that itertools has an accumulate function, that does the same but gives you an iterable for the inbetween values. It has minor differences: the place of the iterable and the function are switched and the inital value is a pure keyword argument, still nice to have it, so:
print(list(accumulate(range(1, 6), lambda a, b:a+b, initial=20)))
will print [20, 21, 23, 26, 30, 35].

oida
Автор

Now with about a few years of experience doing Python professionally, I’d confidently say I would never use these kind of functions over list comprehension, for a few reasons.
1, they’re difficult to read and maintain.
2, they’re an extra functionality you’d need to import in.
And 3, most importantly, rather than remembering these myriad of Python functions, it’s better to learn the core and use Google for the rest when and if you need.

ThatSayanGuy
Автор

please make a video about class methods and object methods(all kind of it ) and the differences between them just for clarification (and also usage of them in real situations)
because the way you teach is amazing and thank you very much for your consideration

alidev
Автор

I use join to make a string out of a list of strings. Also I add format to do the same result as you got with "INIT". You have not persuaded me to use "reduce". :)

alexanderoverchenko
Автор

So you can very easy count the ! I don't know how to say in english but when you understand 2! = 2, 3! = 6 etc. In polish it's silnia, 2 silnia, 3 silnia itd.

Pawlo
Автор

Do you have an overall overview video on functools like itertools?

mahdirasouli
Автор

if you skipped all illegal moves in that chess game, the only legal move would be c3 (white's move). this is assuming that you still alternate when a move is skipped.

localhost
Автор

As a C programmer, this has broken my mind for a second. Then I realized there're no macroses and inline functions in Python

robertobokarev
Автор

Thank you for your video. I just wonder why you don’t have these on Facebook.

HungLe-pkoz
Автор

Functools does seem to be interesting, waiting for more videos on them

Oler-yxxj
Автор

I am starting using Python, and the difficulty that I have is to see the list command or function to make a study of each .Were to look for ?

davidconiglio
Автор

I wish I could write these like
[1, 2, 3].map(lambda x: x*2).reduce(lambda a, b: a * b)

sangchoo
Автор

not clear why it is better then "map" . what is difference ?

denischirtulov
Автор

these type hints just clutter the code.

No seriously. What if I want to reduce a list of np.poly1d instances, because I actually need hard math at work. I don't need a product function saying "I take floats", and I sure don't need floats if I am computing factorials. It's totally unpythonic. I mean what's next "fprintf"???? We need to keep this in check.

DrDeuteron
Автор

Sir please explain class and objects with full details not in shorts please
I am having exams to join a company which is having a big important question with class topic
Please sir 🙏🙏🙏 it will help my career

yasinsk
Автор

For a guy 3 years into python, you should consider showing us real projects on yt instead of just simple 3 line snippets

Sinke_