RUVIDEO
Поделитесь видео 🙏

Intermediate Python 8. Zip 영어 파이썬 코딩영어 смотреть онлайн

📁 Обучение 👁️ 16 📅 03.12.2023

LC training(4:13) - Sometimes it might be tempting to take this line and instead maybe we're going to we could write this we could print x y and we'll just do x y for x y in zip x y This seems good right so we'll run that and we get what we expected and then later on If we decide we wanted to print x Is x what we expected? X to be 1 2 3 4 yep That is what we thought x was going to be Because we know that these are temporary variables right in a for loop but hmm Is that the case? so what if we said for a b or print a b for a b in zip x y and then we print a after that So there's these variables okay we get a is not defined But what if we did the same list comprehension just in a typical for loop Well we would say for a b in zip x y print a b same thing i'm just going to comment this out But it's the same it's going to produce the same output anyway But see what happens on the print a Huh looks like tht a was stored what's more is instead of before when we said in the list comprehension example for x y or print x y for x y in zip x y we recognize that these were jst temporary values they weren't actually being stored But in the for loop they are stored So when you say printer for x y and zip x y this will work It's going to work it's going to be fine No one's going to loose their shirt But when we go to print x afterwards let me just comment this out It's overwritten x y so you might find yourself in a scenario where you're not using lst comprehension you're writing a simple for loop And because you've gotten away with this in list comp you think you're going to get away with it here but you don't And then you decide that you're going to iterate again like for x or for i in x or something like this you're going to continue using that x variable and it's just not going to work So just remember that in list comp these values aren't going to overwrite our original variables and in fact they're not even stored after the loop But or after the full iteration is complete but in regular for loop that value is stored and it's going to overwrite your old variables So if you get in the habit of just using the same variable names as you're iterating over it it's probably a bad idea because you're gonna you might find yourself in a situation like this

Summary & Code results -


zip takes elements from multiple iterables and aggregates them into one where we basically share the index value.
remember that we learned in the previous class: () parentheses, [] square brackets, {} curly brackets. in python we call it tuple, list, dictionary data type respectively.

x = [1, 2, 3, 4]
y = [7, 6, 2, 1]
z = ['a', 'b', 'c', 'd']

for a, b, c in zip(x,y,z):
print(a,b)
print(zip(x,y,z)) # object only
print(list(zip(x,y,z))) # three iterables
print(dict(zip(x,y))) # two iterables
[print(a,b,c) for a,b,c in zip(x,y,z)]

[print(x,y) for x,y in zip(x,y)]
print(x) # not overwritten

[print(a,b) for a,b in zip(x,y)]
print(a) # overwritten

for a,b in zip(x,y):
print(a,b)
print(a) # overwritten

for x,y in zip(x,y):
print(x,y)
print(x) # overwritten
--------------------------------------------------------
1 7
2 6
3 2
4 1
zip object at 0x000001FAAABB4AC0
[(1, 7, 'a'), (2, 6, 'b'), (3, 2, 'c'), (4, 1, 'd')]
{1: 7, 2: 6, 3: 2, 4: 1}
1 7 a
2 6 b
3 2 c
4 1 d
1 7
2 6
3 2
4 1
[1, 2, 3, 4]
1 7
2 6
3 2
4 1
4
1 7
2 6
3 2
4 1
4
1 7
2 6
3 2
4 1
4
[Finished in 242ms]

if you get in the habit of just using the same variable names as you're iterating over it, overwriting issue arises. fix your habit.


원본 비디오: https://www.youtube.com/watch?v=bMxEU0iG-KA&list=PLQVvvaa0QuDfju7ADVp5W1GF9jVhjbX-_&index=9

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Intermediate Python 8. Zip 영어 파이썬 코딩영어» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.