пожалуйста, возвращайтесь позднее
пожалуйста, возвращайтесь позднее
PARLANTE: This morning, I talked about strings, they're just the most basic stuff, and then we had the string exercises. So the time for the rest of the day I'm going to talked about lists and tuples, what are their structures. We'll have — had a little exercises about that, and then I'll finish off talking about dictionaries and files, chart tables, and then we'll have a large exercise, and that will complete the day. So that's in line for today. I'll probably get you out here around, I don't know, 4:15 or some like that. All right. So let's talk about another Python type, so let's fire up the interpreter here. So I did strings. So the next topic I'm going to show you is the lists. So the lists is in a — appears in square brackets. So if I wanted a lists of like the numbers one, two, three, that will look like that, like — I mean I could tie it into a variable to make it very much like my last example. The elements in a lists, they often are of the same type but there's no requirement, so I could have like "1, 2," and then like "aaaa", — oops, okay. That's probably — oh, three commas. I'm sorry. So, it'll give a list of a, you know, different types. In reality, mostly, you'll have a list of all the same thing for just, you know, just sort the most intuitive case. Now, Python has this sort of design idea that instead of having, you know, one syntax for strings and another syntax for list or whatever, Python tries to use the one syntax very consistently for all things, and so this is a nice quality. It means when you're learning it, there's less to memorize. So, for example, the length function for lists is just the one we learned before. So, yeah, I could say "lan(a)", just like for strings. And in fact, many of the bits of syntax or operations for strings were countless as well. And so Pythons are deliberately consistent. So, for example, I could do a "+". So I could say, well, I have the list "[1, 2, "aaaa"], you know, "+ [3, 4]". And like with strings, we've seen that, right? It puts them together to make a bigger string. With list, they're like, put some together to make a bigger list. So one difference that list have — I'll set this back to "a = [1, 2, 3]. Is what is — what is the equals to? So if I say "b = a", "end. The key thing to remember here is this does not make a copy. What this has done is there's this one list sitting in memory somewhere, and it used to be that "a" was pointing to it; and now, "b" is pointing to that same list. So there's one list, and they're both pointing to it. The way you could tell, all right, we do a little experiment — oh, I'm sorry; I really didn't to talk about. How do you refer to the — an element inside of here? Yeah, it's just like, just like in the string. So, if I say "a ", that's the first element, remember? So I can check my experiment by using this on the right hand, so I'll say, well, I'll set "a = 13". I'm going to change that first element; lists are mutable, you can change them. Unlike strings, Strings are the ones that don't' change. So if I look at "a", it's now different. But if I look at "b", it's different also. So this kind of shows how they were just pointing to the one thing. If you want to make a cut — mostly, you're just having the one list or whatever it is, and having pointers sort of sprinkle through your [INDISTINCT] all pointing, all sort of — I could say, sharing that data structure. For most part, that's just totally fine. You shouldn't — [INDISTINCT] block that out.