 Hi, everyone. And we're in the second half of the course right now. So if you've made it thus far, congratulations. And we're going to get into more interesting topics. The first half is just basically trying to teach you constructs, I think, probably better in most programming languages in one form or another. But as we get to the other side of this course, I think there are some additions that Python has that really make it, I think, very unique as a programming language. And part of it has to do with, I think, just how smartly it was put together. It seems like it was an answer to so many things that were so unnecessary. And people just got in this rut of doing things the same way in every single programming language. And then no one was really thinking outside the box anymore when it came to newer programming languages that you just thought, oh, the syntax has to be like this. And for instance, when it comes to class definitions and so forth, or defining an array in a language like Java, I get why they have it that way. But it's cumbersome. Whereas Python, it's just one-liners can pretty much do everything. And that's where I think the beauty of these data structures we're going to talk about today lie. It's just they do exactly what they're supposed to do. They do exactly what you want them to do. And there's not a lot of overhead to get them up and running. So today we're going to talk about tuples, sets, and dictionaries. And you'll see what I mean as we kind of go into this. I'll get away from that because we're going to start out with tuples. And so a tuple is just like a list. It's basically it's an immutable ordered container. So let's sort of pick apart what that means. Immutable means that you can't change it. And it's ordered, which means it kind of acts like a list. And so if I go ahead and do something like this, the syntax for creating a list looks like so. And I'm sorry, for a tuple looks like this. So the left parentheses and the right parentheses are the syntax for creating a tuple. So it almost looks like you're creating a list with the comma separated values. But instead of the square brackets, you're using the parentheses. And so if you go ahead and print this, it's going to get printed. It's going to, again, almost look like a list. And except if we print the type of it, if we print the type and say, let's say type of this variable like so, then it should tell us that we have what's called something of a class tuple. And so everything about the tuple is almost like a list except that it's not mutable. You can't change it. You can't change the values. It's right protected, basically, if you want to think about that. It would be safe, almost safe, to make the statement that a tuple is a right protected list. And so in other languages, you might have the ability to create, for instance, constants. And so there'd be some computational equivalence to me saying something like a tuple, although, again, some people would cringe when I say this. But if you programmed in another language, trying to make the connection, if you have a tuple, it's kind of like a constant list if you want to think about it like that. And that's all there is to it. There are places within programming where you're in a don't touch mode. You're not allowed to change these values once they're set up. And the tuple is the vehicle for that type of a construct. So if I went ahead and said, OK, well, let me go ahead. And since they're ordered, by the way, since they're ordered, you can use indices just like you would for a list. So I could print a 0. And if I go ahead and do that, I know we're all experts at this point. We're referring to the 0th element. So we're printing out the value 3, because that's the 0th element. Or if I wanted to print element 0 through 3, something like this, then I'd see the elements 3, 4, and 5. So you can use indexing and slicing. And all the tools that lists have been endowed with for indexing the elements contained in a list carry directly over to the tuple because they are ordered containers. Again, the only thing that you can't do is change the values. So if I went ahead and now that I've printed these out, if I went ahead and said, OK, well, I'd like to set A1 equal to 456, like so, then I would get a no-no from the interpreter because you can't change the values. That's not the point of the tuple. And that's all there is to it. Everything that you know about lists, like I said, for the most part, anything when it comes to indexing carries over. And then I think the key to any programming language has to be, it's how flexible it is. And whenever you create a programming language, you want to be able to allow the user to do pretty much anything in the universe to compute anything that's possibly could be computed. And it may turn out that you're in a jam and suddenly you realize you created a tuple and you want to be able to modify the values somehow. And so again, Python obviously has to have that flexibility. So you might say, well, I thought I wanted a tuple, but maybe I'll go ahead and set, I don't want to do something like this. In other words, I can take the tuple and I can turn that data into a list if I want to. And you can see when it first starts out, it's got the parentheses next to it. And later on, it's got the brackets next to it. So to your choice, you're the programmer, you're the expert, you know what you're doing. There may be a need to do that, but this is just a type conversion. So you should be able to see that you've changed the tuple into a list, but you can go ahead and test it for yourself. So there are places for type conversion and you want to have that flexibility at your fingertips. So that's about all I really want to say for tuples. Because if you know about lists, you know about tuples in terms of indexing, in terms of how you might use them, if you just want to have data that you want to be immutable, you don't want to change it. And then if you backed yourself into a corner for some reason or another and you had to get out of the tuple mode and get into some other mode by some type conversion, I think those are probably the three most important things that I would want to say about tuples. Again, if you know how to write loops and so forth, let's see, yeah, we did loops. And we did control structures and stuff. So yeah, OK, that's about it. OK, so that's all I want to say about lists. The next type that I want to get to are sets. OK, if there are no questions about tuples. Any questions? As of right now, we don't have any questions. But they're a little bit behind. So I like to stall for a second, just saying. This got me all into the tuple lengths from going to couple, triple, quadruple, all the way down to the 1,000th parallel is a mellupal. Maybe I'm saying that wrong. But that's to the 1,000. But it looks like we're all good here in the chat. So I'll let you get on to the next section. Thank you for that little tidbit of information. I just used up one neuron to go ahead to keep that. OK, let's get on to sets and dictionaries. Because now we go into a realm that is important for a number of different reasons. First of all, when it comes to sets in general, just to remind you of set theory, let's say, and just the concept of a set. Maybe when you were in grade school or something like that, you'd have a set. You'd have a universe. And then inside that universe, you'd have a set A. And then you'd have a set B. And you draw these at circles. And there'd be elements in the set A and elements in the set B. And there were concepts like unions and intersections. And then a set difference. You take the difference of two sets. This is usually when I start to teach this. These are the places where I start. Because I'm trying to appeal to some recollection, possibly going all the way back to fifth grade, fourth grade, or something like that, where you learned what a set was. And then so the union, they would draw pictures like this in what was called a Venn diagram, where the union would be the combination of everything that's in A or everything that's in B. The intersection was the overlap between the two sets. So this was the intersection right here. And then I'm not going to mess up my diagram with the difference. But when you take A minus B, then you take whatever is in A and less B. So that would be something like A less B would look like that. Because you're throwing out anything that's in B. You're basically throwing out the intersection, if you want to think about it like that. That's a good way to think about it. So unions, intersections, and differences are important. You want to be able to operate on sets. Whether you realize it or not, you've already used one instruction in Python if in the course where you have made a decision if a value is an element of a set in some sets. It's the Python word in. So that's a reserved word that you're asking the question, is that element in the set? In disguise, that's what you've been doing. I haven't really emphasized it too much. But some loops that we wrote and some that are in the course, you say like for val in something or other, that you're asking the question, is that an element of the set? But these pictures are very, very important to have. If you're doing Boolean algebra, the union is related to the OR operation, A or B. In other words, X is an element of A or X. Not either, it's not exclusive. X is an element of A or X is an element of B. Intersection is the Boolean and. If you're taking the intersection between two sets, basically what you're saying is that there's a value X that's an A and it's in the set B. It's simultaneously in both, so that would have to be this. You see, so there's a deep connection between Boolean algebra and the set operations. Not too much of what we get. Well, actually, I think I do ask some questions to at least make you aware. I think when I made up some of the quizzes that I brought up, like De Morgan's Law and stuff like that, and that comes from Boolean algebra. But coming into that, when you're coding, these are the pictures that you have to have in your head when you're thinking about the, if you want a quick way of evaluating the difference of the intersection or the union, this is definitely the picture. These are the pictures you want to have in your head. So with that said, sets are unordered. They are unordered. They're not ordered. They have no ordering to them, which means you can't index the elements in the way that you would with a list or a tuple. So there's a stark difference in this kind of a data structure, for a number of different reasons, I'll try and get to it, but they're unordered and they're mutable. In other words, you can change them, okay? Just like lists are mutable. So I could set up a, and so the syntax now, so here's where learning the language is key because now we've talked about square brackets for lists, parentheses for tuples. Now we have to learn the squirrely bracket for a set. So that's the syntax for a set and we'll just print it out. And again, there is no ordering to a set, first of all. So what'll happen sometimes is you can print out sets and they'll be thrown out in some order that might go against your expectation of some ordering that you might think that the set might have in terms of its elements. And that's because they're not ordered. If you want them ordered, if you want them indexable, that's why you use a different data structure to do that. So if we run this little piece of code here, now you'll see that you have a class set. And the main thing to note is that sets don't have copies of elements. So if I do something like this and run it, the set will only contain the values three, four, five, six and seven. There's no repetitions allowed in a set. Once you've got the elements in there, that's the end of the story. You don't need to put another one in there. Python will figure out that you're trying to make a copy and it won't allow it. So that's how a set is handled within Python. And so, again, we're in kind of a different realm, I would say, and it's wonderful because now you're endowed with all the abilities of what you'd like to do with sets. And you don't have to write like a lot of code to, so for instance, it's very common in other languages. Again, it's so funny, I'm not sure I don't wanna taint anyone if you haven't programmed in a different language, but if you have programmed in other languages, you know that you've had to write code that would have data in some type of a structure like an array. And then there'd be some new code that you'd have to produce or some method that somebody else wrote that where you'd have to determine whether or not you have a unique element or not. Is that an element unique? So people have written historically functions like the unique function and you don't have to do that, that's all done for you here. And that's why I say Python's a smart language. It really sort of, it absolves you of having to do some of the grunt work in terms of getting code up and running. And it's like, bam, it's right there in front of you. So that can be, and if you don't like that, then what you do is you use a different data structure. That's the whole point. Okay, so that's all I'm gonna say in terms of the construction. You can create empty sets. You can do stuff like this now. And you can set up variables that'll prepare a Python to know that, I'm sorry about that, to know that you are planning on using a variable in the future as a set. So those types of instructions and so forth. So that's how you set upsets. And let's see, what else would I want to do here? So here's a little example. I just kind of chuck together just to make things move more slowly because I am like the worst. Well, I don't want to say the word. That's being too negative. I'm not a very good typist. I'm gonna take a typing class, but not today. All right, so let's make believe we've set up these two sets. Now with the squirrely brackets, the curly brackets, set A and set B. And again, print them up. You want to be, when you see code like this, what you want to be able to do is you want to be able to, in some sense, predict how code is going to execute, what values will be contained. And sometimes when I teach students and I say, what's this code doing? I think many times some students will think, well, they have to guess. They have to guess at what I'm asking of them. And that's not what I want to do. You know, as programmers, we don't guess. It's like, you know what the code does. And so what you have to become is a sort of a Python instruction executor where you can execute the instructions kind of in your head as you look at them. So you can go, well, you know, you're gonna print B out. So your expectation is that you're gonna print out B without the repetitions. And then you're gonna take the intersection of A and B. So here's the intersection method. So again, when you create a set now, okay? Just like with any object in Python, you know, there's a whole host of methods that you have access to so that you can perform whatever operations are sensible for that data structure. In this case, well, definitely, you know, intersection and difference and union are ones that I think are very important to understand. So as you see that instruction, you want to look at those two sets and look at the intersection between them. Well, you can see that B doesn't have a three in it. But B has a four and a five. So you expect that the intersection is gonna be four or five. The union is gonna be, you know, three, four, five. It's gonna be, it's either an A or B or both. So it's gonna be three, four, five, on and on, whatever's in the rest of that set. And then the difference is saying, well, now we're gonna subtract off whatever is not in B in this case, take whatever is in the A and remove it from B, basically. So we can predict all of those. And you can see here that originally you had the four and the five, well, let me go forward. So the intersection, I'm going backwards, let's go forward. So first of all, it's print out B. The whole point of printing out B is that there are no repetitions, okay? There's no repetitions. The whole point of taking the intersection and printing that out is to make sure that you understand the intersection operation. You take the union of the two and then you get this print out, okay? And it's important to note again, in this case, Python isn't going to make any effort or not a lot of effort underneath the hood to print out numbers in their numerical ordering, like what your expectation of the numeric, it'll try a little bit, but it's not gonna sit there, blowing out computer time, attempting to figure out the ordering all the elements because that's not what you do with the set unless it's an ordered set. But if you're using an order set, then you're probably, once again, you're using something like a list, for instance. So you've got some hooks in your code that associate not only the set, but then something like a greater than or less than property of some kind. And you have to do that. You have to go through the work of doing that. But anyway, so if you take the union of A and B, you're gonna get this. And then you ask the question, well, when you say E, if you set E equal to eight and you ask if E is in B, you say E and B, it's true, E and A is false. And then the difference removes whatever is in A from B. So you're left with the values eight, nine, six, seven. And it's important to know. I mean, look at this set. This is a perfect example that when I print it out, Python is only concerned because somehow or another, it's got to remove those elements from the set, right? It's gotta remove the elements from B somehow. And again, it doesn't assume an ordering to do that. It just knows that it has to remove them. So in order to remove them, however that works out, you end up with eight, nine, six, seven. So you can see right here, the values are not, they don't look like they looked up here. They look different. They have a different ordering, but they're the same elements. And you could test that. You could, if you had two sets, in fact, let's do that now. This isn't important. This is another operation. Maybe I'll set, so I'm gonna, if it's everybody, well, I'll leave that code up there if anybody wants to. I'll create some new exciting variables. I'll call it x three, come four, come a five, come a six, like this, okay? And then I'll have a y and I'll set that equal to five, come a four, come a three, come a six, like this, okay? So these obviously, these have the same elements. They're not in the same order, okay? And you could say something like this. You'd say print x equal y, okay? And so effectively what you're asking is if they are equal to one another. Oops, my thing is locking up here. So I'm gonna control x that and it will come in here and I'll come back over here. They'll to connect. We're trying my replete. I don't know, there we go. Sometimes. I was very concerned that that was the YouTube. Not the replete, you gotta be worried for a second. No, no, no, it's replete. There we go, that's good. It's the pros and cons of using a free interface. Only a flight heart attack. No, no, no, no, not you, that's good. It's not you, it's me, no, it's good. All right, so. That's never true. So lastly, right here, when you're printing x equal to y, Python is telling you that in fact this is true. These two sets are equal to one another. They're in a different order, which doesn't matter when you have a set, okay? So like I said, I just, I can't emphasize that enough. And as you program, you know, you'll figure out, you know, when you need a construct like a set versus a list versus a tuple. But the beauty of Python is that they're all there. That, you know, you're given that flexibility. And that's, that's important to, it's important at least to know about them because you, well, how about this? So, so, so we could say something like, let's see, if we do something like this. And so what I've done is I've turned, I've turned y into a list. And again, you know, there's been some measure of a decision that's made when you convert the list to a set. And let's go ahead and do one more thing. I'm gonna, let's do this. Let's do that. I just wanna show, well, let me just think. Okay, let's try this. Let's set C equal to this. So it's a list. And then we'll print C. All right. And then if you say D is equal to set of C, then print D, right? So, so what just happened in these two instructions? This is, this is something that you may need to do one day. If you do this for a living is that you'll have a set of objects and you need to, you want to remove repetitions. And again, you could, you could write, you know, like a nested loop to do that. You'd have to do that in a high level language. But in Python, what I did was I created a list and then I, and then I converted it to a set. And then, you know, now what I'll do is I'll convert and then I can convert it back to a list again. If I want to, what letter did I use there? Let's make things going in the way. And so when you go ahead and print the final variable, you know, just this kind of trickery, it's not really trickery, it's actually very simple, but it's three lines basically to remove repetitions from, you know, from a list basically because of sets. And you can kind of, you know, jump back and forth between the different data structures if you wanted to. So this is much, much more convenient. Again, you know, you can call a unique function in a high level language, but I'm saying that you can call a unique function in a high level language, but I'm saying underneath the hood, if you want to write that yourself, you know, you'd have to pretty much write a nested loop of some kind to, in order to guarantee that the object that you're looking at isn't equal to some other object in the list. And this type of gymnastics right here is, like I said, it's three lines just to kind of do away with all that. So again, just kind of throw ideas out there of how you might, in addition to the basic set operations, how you might have the set interact with other data structures within Python. Okay. And so, and the last thing, so that's all I really want to say about sets right now is that you really can use set operations. Is the element in the set, are two sets, quote unquote, equal to one? What does it mean for two sets to be equal to one another? Unions, differences, everything that you would want to do with a set, you can pretty much do in Python with either the methods that are given to you or by some combination of methods. And again, in the course, I ask a lot of questions about taking combinations of, excuse me, what happens when you take combinations of different methods? And again, that becomes sometimes necessary to do so. So if there are no questions about sets, then we can move on to dictionaries. Well, I'll keep my eye out here on the chat, but so far, all good. Dylan says, thank you. So I'll let you know if any other questions come through, but so far, no one's had any live time questions anyway. So I think we can probably give it one more second. I think we're probably good to move on. Great, great, great. All right. And then the last built-in data structure that I think is important, again, so these are all built in, int is built in, float is built in, STR built in, lists built in, right? Sets built in and dictionaries built in. And, you know, you get a tiptoe for, well, here's the deal. Is that if you have a set and if you want it to be ordered, the question is how do you go about ordering the set? How could you go ahead and do that? And the beauty of dictionaries is that you're given the equivalent of an index, so it's called a key. And you use the key to basically index elements within your set. So you create what are called key value pairs. So dictionaries have key value pairs. And every element that you want in your set, you basically connect it to some kind of a key, which is the equivalent of an index. So much so that the syntax for using the key is exactly what you would use for an index in a list, except that you have to use the key. So maybe I'll just again, save myself some typing, because now this is where I would go like so slow. And I just, I don't wanna waste your time with my typing. So that's how it goes. Anyway, so here are two examples of creating dictionaries. And so there's different ways of doing that. You can invoke the dict data type commands to actually, so you can send, so you can drop, this is actually a list of tuples. If you really, really watch this in slow motion. So in fact, let me come back to that one because let's do the first one first. So this would be, notice the left, right curly brackets, for this invocation right here, is that you've got the left curly bracket, you've got the right curly bracket. So it looks like you're creating a set. That's what it looks like. And that's why the syntax is there. I mean, that makes sense. But instead of just having the element V1 or the element V2 or the element V, in this case, I'm using strings. So these are string values. You don't have to use strings. I'll have other examples where you can use numerical ones. It's irrelevant. And you can have anything as a value basically. You can, and that's the beauty of diction. That's the beauty of all the data structures in Python is that you can drop any value in the universe that's a valid data type, either because it's built in or because you defined it. So these values can be pretty much anything that you want them to be. In this case again, I've just decided to use string data. But the key is K1, K2 and K3. Again, you don't just have to use text. You'll see other examples where you can use, for instance, numbers. The point is that the key is connected to the value. So the construction of a dictionary has to do with constructing key value pairs separated by a comma, just like you would for a list or a tuple or a set. And you're using the set notation. So that's the syntax. And then depending on, again, there has to be a measure of flexibility in any programming language. So I'm not out to confuse anyone, but you need to have different tools at your fingertips at any given day because of the type of data that's been handed to you. And if data comes in a certain form, what do you do? How do you handle that? So in this case up here, I'm actually using the dict command. That's go ahead and notice I've got a list of tuples. And the tuples are gonna be considered to be the key value pairs. And of course those tuples are comma separated. So this is another way to invoke a dictionary. And if you, I can move my little zoom thing over, you can see that these two commands do exactly the same thing. So this is probably the quickest, fastest, simplest way to build a dictionary. But if you have data in other forms, Python is very flexible in the sense that you can take one kind of data and then plop it into a dictionary. If that's the corner that you've been backed into, sometimes when you program, if you do this for a living, I mean, it's like you're at the mercy of the people who give you the data and they don't care. How they save the data, they just like look, this is how it is and you gotta, so you wanna have that flexibility to deal with individuals who aren't thinking like programmers and just kind of like throwing their data into a big garbage can and asking you to unravel all of it. So that can happen. Anyway, so you need that flexibility. Anyway, so these are the key value pairs and this is how things get printed out. So the dictionary is kind of like the answer to the question, is it possible to index elements within a set? And the answer for sets is no, you can't do that. The answer is no, by construction. But for dictionaries, the answer is yes. So now when it comes to the question of mutability, you'll see sometimes people will consider dictionaries to be in some sense immutable and what's immutable about dictionaries are the keys. You can't change the keys. You can't mess with the keys. It's kind of like a database. It's like once you've made a decision for the key value, not the value, the key, I'm giving myself a big stuff. You can change the values, but you can't change the keys. It wouldn't make sense to do that. It's like the whole point of setting up the dictionaries is with the intent of collecting data and putting it in a form where you're using references to access sets of data. And I'm not gonna go off on a tangent to, well, I shouldn't even go on this way. 10 seconds. No, I'm not even gonna say it because it'll get too confusing. That's good. So anyway, let's stay focused. So that's how you can, so now what I can do is, because I have the key, I can index into in some sense, I can index into a dictionary like so. So maybe I'll say, you know, print Y key K1. And what you get out of it is you get the value V1, okay? So this key now is being used as an index and that's all there is to it. It's just, you know, if you ever were in the state of complaint and you're like, well, I can't index the values within a set and that's what I wanna do. Well, this is the answer to that complaint basically. And it gives you a lot of power when it comes to the construction of like tables, like spreadsheets, you know, like an Excel spreadsheet or something like that. You know, you've got columns, you've got names for columns, possibly names for rows as well. And we have names for columns that name of the column in some sense. And also the indices that define each cell, you know, give you access to the value that's contained within a cell. So there is a little bit of similarity between the construction of a dictionary and handling, you know, data sets that require key value pairs. And again, I'm going to stop myself. Okay, stop it, stop, get back to the program. Okay, so that's how, and then of course you can set that particular value if you wanted to, let's say K1, what is mutable is that you can set the value equal to, you know, something else if you want to. And that's the whole point. It's like, you know, if you look at this syntax right here, you'll see that it looks exactly like what you would be doing for a list, except the index is weird. It's not like, and it could be though, you could number these values, you know, 0, 1, 2, 3 and make it look like you're accessing a list. So I'll get to that in a second. But when I print these values out, you'll see that you can actually change the values. So in that sense, the dictionary is in fact mutable. Okay, so now you can see after I print it out, I put the 345 and I use the reference as K1. So I can create, let's make believe I create another, let's not make believe, let's just do it. Okay, let's go ahead and create the indices 0, 1, let's say 2, like that. And so now if I run this code, I have these keys. So now what I can do, watch this in slow motion. I can actually, and so here, I can change the values. Now, this is where context and syntax is everything. So now I've taken the element that with the key is 0 and I've changed it from this text, this string into the number 345, okay. And so listen carefully, you know, when you, if you look at somebody else's Python code and you see an instruction like this, context, just like in a language, context is everything. You know, is it, when if I say 2, you know, do I mean TO, do I mean TOO, or do I mean TW? Over here, over here, what I've done is I've almost looked like I've made reference to a list, possibly a tuple, or in this case, a dictionary with the key about the key equal to the number 0. And it looks exactly like the syntax for what you might use for other data structures. So context is everything. And you need to make sure you understand that this is still a dictionary and that those values are what they're supposed to be, okay. So that's the introduction to dictionaries. A couple of more important points to bring out is, let's see here, just pick something out of the blue. Let me think for a second. I just wanted to do something. Oh yeah, okay, go get it. So here, how about this, here comes something. So once again, with regard to, you know, useful methods, okay, methods that are useful for given data structure. When you use, for instance, lists, you know, for instance, like the append method, okay, because you're afforded a whole bunch of methods whenever you have a specific data structure. And again, the course goes out of infinitum into that. But, you know, you want to at least, you know, you got to know the append operation as a whole, you know, you can see the whole list of methods, some of which you may use, some which you may never use, but it's the same thing for dictionaries. Dictionaries have their own list of methods. A really important one to know, probably at the top of the list is the update method because oftentimes you're not doing onesie twosies with these kinds of things. I mean, you can have like a lot of data and you can have a lot of data contained in one dictionary and you can have a lot of data contained in another dictionary. And under those circumstances, you might want to merge those two dictionaries for one reason or another. And when you merge them, you want to do something like an update function, right? So here I've got a dictionary with the values, keys one, two and three values, one, two and three, again, not the most exciting dictionary. Well, the dictionary nonetheless, oopsie. And then another one. And if you want to update, let's say the Y with the X, what'll happen is that is now what you can do is you can connect effectively connect dictionaries together. And that's probably, you know, you may, like I said, you may do onesie twosie types of instructions where you want to access one singular value and you know the syntax for doing that or it's a left bracket, right bracket. But if you wanted to connect up large amounts of data, this is the method that you would want to do. So once again, you'll develop expertise when it comes to using dictionaries. But this is probably more the correct context. It's the idea that you've got lots of data on the left hand and lots of data on the right hand. And you're like, I just want to check these two things together into some kind of a set with a bunch of keys. This would be the method for doing that. What's some other stuff that we can do? Here's a good one. So this I'll just lift this right out of here, right out of the course, we'll lift it, let's say. And so when you go to run this code, you're going to create, you're letting Python know that you're creating a dictionary. And so the key A is going to be set equal to alpha. The key G is going to be set equal to omega. And then we can go ahead and print it out. And then you can go ahead and, as I just showed you a second ago, you can change different values. But this is also very, very important, extremely important. Because the dictionary is meant to be a generalization of a set. And if it's a generalization of a set, the question is what's being generalized? And what's being generalized is the fact that the elements of the set are the keys. They're the keys, not the values. And because the keys are the elements of the set that point to a given value, when you ask a set question, like is the element character A in a set in the dictionary Z, you're asking about the key, okay? You're asking about the key. So the set operation is the character A and Z is with respect to the key, not the value. That's an important distinction to make. That's important to know, because that can affect how you program as well. I'll try and give an example of that in a second. You'll see why it's important. And maybe I'll even show you, well, I'll do this first. So if we run these two, we know that Z is a key and A is not. So this is important. An important question for dictionaries is something like, is this key in that dictionary? Okay, is this key in that dictionary? You might ask a question like that because you might have a key and you wanna use a key and you wanna make sure that it's not already in the dictionary because obviously that wouldn't be good. You can't have one key referencing two things. That's not gonna happen. Python will stop you from doing that either by wrecking your dictionary or you're not doing what you wanted it to do. So that would be a no-no. But the point is that if you ask the question, is the key in that set, then you'll get the value printed out. So this is saying, print the value if the key is in the set. So this is a very, very common thing that one does with dictionaries. If, because you don't wanna make reference to a key that isn't in, because that's gonna give you, and we'll get about, what is it, two or three sections from now, units from now on exceptions. Python will take exception to you attempting to use a key that isn't in the dictionary and you'll get a key value, what's called a key value error. And that's an exception. So we'll get to those. So the way that you might write code is before you, I mean, the sensible way to write it if you don't want your program to blow up is either you create some type of, try accept clause of some kind, or if you don't wanna use that vehicle because we haven't gotten to that unit yet, you can just use a simple if statement. And the if statement is checking in advance, where it's asking the question, is it in the set? So in this case, I guess what I'm saying is this, let's do it like that. And so you're gonna get an error. It's not gonna like that, okay? Because you made reference to a key that wasn't in the dictionary. So this is a very important chunk of code right here. If you're writing good code, you're always gonna check keys, keep on saying key values, but because I'm thinking key value, but you're always gonna check the key before you make reference to the key. There's something's gotta be done on the programming end to do that. Python's assuming that you are all responsible programmers and that's kind of how it works. Other stuff, let's, oh, okay. So what I was gonna say before was this. So let's make believe that we created this dictionary right here. And so we do this. So if I were to say something like just, so when you perform the set operation, if you wanted to do a variable conversion of some type setting, typecasting, and you turn Z, which is currently a dictionary, into a set, what's going to happen? What's gonna happen is that Python is not going to extract the values as the element, okay? It's going to extract, because it has to make a decision. You see, it has to make a decision because sets are only allowed to have singular elements. The element could be anything. The element could be the kitchen sink. If it's defined, if you've defined it properly. But the only thing that's gonna get pulled out are the keys, if you make a conversion to a set. So that's just a, you know, that's a syntax decision on the part of the language. So you just, but that's oftentimes healthy to know. It's a good thing to know if you ever, if you wanted to convert, if you wanna get your data, you have to go to a little bit more great length to get the values out. If you wanted to, you know, drop them into some other data structure of some kind, which brings me to, let's say, for instance, this, chunk of code here. So here, what I've done is I've created a function because now we wanna kind of tie in these last couple of minutes, just tie everything together up until this point functions, loops, if statements, and dictionaries and what have you. So we're talking about dictionaries. I created dictionary. Again, it has the keys, in this case, I've created keys v1, v2 and v3 as strings and my values are one, two and three. And then, let's see here for a second, okay. And then, and then a function that is, what's gonna happen is that we're going to drop the dictionary into the function and we're gonna be, start searching for the value two, okay. And we might wanna know the key that's actually associated with the value two. I mean, there's a million different things you can do with dictionaries, but I'm just trying to show you one possible way that you might want to search a dictionary. You know, you might end up having to do this where we're going to, the loop is going to be based upon sort of cycling, iterating through all the keys in the dictionary D. And then if the dictionary element that associated with that key is actually equal to the value, then you go home. In this case, what happens is that you'll return an empty dictionary if it's not on, if the key is not there for that given value. So what happened was is that the key associated with the value two was found. And then if there is no value, three, let's say, three is on the, sorry, let's try set. And then you get an empty dictionary back if seven is not, isn't found. So just a number of things I wanna say, I'm trying to unravel all of them. First of all, this code is useful because it takes you to kind of like a culminating point where you can write a function whose input whose input is going to be a dictionary. In addition, a lot of times what you're doing with dictionaries is as you are with many different data structures as you're searching for values, you have to kind of somehow or another have some principle methodology for cycling through all the values and whatever data structure you're using as you cycle, iterate from one to next to the next to the next if it's a sequential processor. And so in this case, it's also showing you, again, just to remind you when you write loops that you don't have to write, you can, there are implied iterations. You can, the iterations are implied by cycling through the values within a set, for instance. So notice, and this is another indicator right here that you've got this set operation and you're searching for keys in the dictionary D. So just like I showed you a few seconds ago, like when you apply the set operation to a dictionary, the keys are what are considered to be the elements within the set and therefore, okay, and therefore when you write a for loop that you can cycle through the keys in that dictionary, for every key that's in the dictionary. So this is a set operation and you're basically creating an iterator based upon the keys. And then finally, a simple if statement for, and this again goes to show you the power of the dictionary is that the key is acting like an index and therefore the index syntax is what's here. So Python is very sensible. It's sensible in the sense that, okay, well, we've got lists and we've got the left bracket, right square bracket. You've got tuples. All right, you gotta remember that you have parentheses. When you have sets or dictionaries, you use curly brackets because they're both in some sense, you know, the dictionary is a generalization of what you understand to be a set. And then because of that generalization, the whole answer to the question, I'd like an ordered set. Well, the way that we're gonna do that is we're gonna create these things called keys and the syntax for using those keys is exactly like how you would index, you know, an ordered container of some kind, like a tuple or a list. So it's, again, it just, it makes a lot of sense, you know, as if you can get by and memorize the left bracket, the parentheses for tuples and then the curly brackets for sets or dictionaries, the indexing syntax, it just falls back on what you know for lists again. So again, just an example of a function, a for loop and if state, you know, for and if statements, dictionaries and I think that's, you know, a good stopping point. I think that's all I wanna say for today. I'll take some questions if everybody has questions or, you know, I think, yeah. That sounds great. I think mostly just people saying good, thanks, all this kind of stuff, but I'll let them buy a little time and since we have a little time, I'll pose an off topic question for you potentially while we wait to see if people do stuff. But again, everyone, this is Unit 6 of Introduction to Python. All of the links are in the description below and in the chat. Make sure you start from the beginning and catch up to us. So my question to you is at the beginning, you said this is the moment where like this course really starts diverging into Python itself, right? So my question is, and I kind of think of this as like a video guy, like, you know, there's a lot of different programs to video edit, right? Like if you understand the concept of nonlinear editing, like it's mostly about learning the terminology and the layout and like the specifics of those programs, right? Like someone's like, hey, do you know how to use this program? Like I can figure it out. Would you say kind of the same? Like if you understand the basic concepts of like maybe coding in a different language, would then Python be learning like the specific terminologies and quirks? Like dictionaries are just like the place where you like store the key values so like people might know it as like a map or a hash, but if they knew it, would they know it or? Yeah, I mean, so like I said, like some people look at dictionaries as hashes, for instance, so other languages have constructs for hashes. And so, and I think that's, you know, the funny thing is that every language when it sees, even if it doesn't have it as things at its inception, they're added in response to other languages. And so, you know, with the flexibility of, you know, of Python, you know, for instance, with regard to like list operations and so forth, you know, there are, you know, extra packages that you can import, you know, into other languages like a Java, for instance, that would give you that same flexibility. So even if a given language doesn't have the ability to do hashes, oftentimes what will happen is that they'll write libraries where you can import that library and then basically have all the power that would be afforded to you in like a Python. So, you know, the answer is yes with an asterisk because it depends, you know, on, if you're talking about sort of the core language or extra add-ons, you know, that have been thought of after the fact because some other language, you know, you saw some other language doing it and then you've got to import libraries to do that sort of a thing. So these days, like I said, there's so much crossbreeding, you know, the, I think when you learn one language for the most part, you have an expectation, if you program another language, you have an expectation that it's gonna do mostly everything that you were able to do in the other language. And for the most part, that's, you know, you could say that's true. I think when you get into some of the modules in Python, they are a little bit more, I would say, advanced and more curated than other languages. So my base answer is, yeah, I mean, there are definitely, you know, other languages that have, allow you to like build hashes and so forth. And, you know, those are dictionaries effectively. So for that, the answer is yes. And then there's other stuff, like I said, there are add-ons, you know, that people made in response to languages like Python after the fact. All right, well, thanks. That was great for my personal investigation. I don't know if anyone else liked it. I'll let you know next week. Give us any comments. But yeah, no, so that's great. Again, everyone, basically I did the closing before, but definitely check out the course. We'll be back the same time next week. Again, thank you, Dr. Sack, educational as always. As I said, the comments, nothing but glowing. So again, thank you everyone for joining us.