Тёмный

Python Under 5 Minutes: Reduce Function 

Legion Script
Подписаться 4,9 тыс.
Просмотров 137
50% 1

In this video, we will go over the reduce function to iterate over a collection of values and compute a final value. We will look at a few different examples and we will go over how to use lambdas with the reduce function.
Code:
github.com/legionscript/Reduc...
Free Structured Courses on LegionScript.com:
www.legionscript.com/

Наука

Опубликовано:

 

31 авг 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 3   
@mattshinay
@mattshinay 10 месяцев назад
I’m an Excel guy and just starting out in Python. Why do you only have to identify variables a & b, yet all the values in your list are added?
@LegionScript
@LegionScript 10 месяцев назад
The reduce function is a built in function that will take two values, one of them being the result of the addition (we are starting at 0 except for that last example with an initializer) and the other value being the next number to add (each value in the list one at a time) and we will pass both of those values into the add function, it will call the add function for each number in the list. So what the reduce function is actually doing would look something like this: add(0,10) -> add(10,1) -> add(11, 2) -> add(13, 3) -> add(16, 4) -> add (20, 5) -> return 25 (because 5 is the last value). With each time the add function is called, the a variable will hold the current sum value up until that point, when there is nothing left to add, we return the final value. Hopefully that helps clear up any confusion with this, let me know if that still doesn't make sense. Thanks for watching!
@mattshinay
@mattshinay 10 месяцев назад
@@LegionScript Thank you for taking the time to write out such a detailed response. I understood how it got to 25, but didn’t understand the fundamentals. Your explanation is very helpful for a Python newb.
Далее
Python Under 5 Minutes: Floor Division
5:00
10 Nooby Mistakes Devs Often Make In Python
24:31
Просмотров 50 тыс.
Send this to an artist… 😉 #shortsart
00:19
Просмотров 6 млн
Lasagna Soup @Lionfield
00:35
Просмотров 10 млн
Python 101: Learn the 5 Must-Know Concepts
20:00
Просмотров 1,1 млн
AWS with Python: Mastering Lambda Basics
9:44
Python Lambda Functions??
4:30
Просмотров 164 тыс.
Studying Algorithms in Python
10:13
Просмотров 20 тыс.
Deploy Django with Digital Ocean App Platform
19:29
Просмотров 8 тыс.
Getting Started With Pandas
28:42
Просмотров 110
Functions in Python are easy 📞
10:38
Просмотров 413 тыс.
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00