 Hello everybody. Today we're going to be talking about data types in Python. Data types are the classification of the data that you are storing. These classifications tell you what operations can be performed on your data. We're going to be looking at the main data types within Python, including numeric, sequence type, set, boolean, and dictionary. So let's get started actually writing some of this out and first let's look at numeric. There are three different types of numeric data types. We have integers, float, and complex numbers. Let's take a look at integers. An integer is basically just a whole number, whether it's positive or negative. So an integer could be a 12. And we can check that by saying type. We'll do an open parentheses and a close parentheses. And if we say the type of 12, it's going to give us an integer. Or if we say a negative 12, that is also an integer. We can also perform basic calculations like minus 12 plus 100. And that'll tell us it is also an integer. So whether it's just a static value or you're performing an operation on it, it's still gonna be that data type if those numbers are whole numbers, whether negative or positive. Now let's take this exact one and let's say 12 and we'll do plus 10.25. When we run this, it's no longer gonna be a whole number. It'll now be a float. So let's check this. Now this is a float type because it's no longer a whole number, it's now a decimal number. And the last data type within the numeric data type is called complex. Let's copy this right down here. Now personally, this is not one that I've used almost ever but it is one just worth noting. So you can do 12 plus and let's say three J. And if we do this, it's gonna give us a complex. The complex data type is used for imaginary numbers. For me, it's not often used but if you do use it, J is used as that imaginary number. If you use something like C or any other number, it's gonna give you an error. J is the only one that will work with it. Now let's take a look at Boolean values. So we'll say Boolean. The Boolean data type only has two built-in values, either true or false. So let's go right down here and say type true. And when we run this, it'll say bool which stands for Boolean. We can do the exact same thing with false and that it's also Boolean. And this can be used with something like a comparison operator. So let's say one is greater than five. And let's check this. This is giving us a Boolean because it's telling us whether one is greater than five. Let's bring that right down here. This will give us a false. So it's telling us that one is not greater than five. And just as we got a false, we can say one is equal to one and this should give us a true. So now let's take a look at our sequence type data types and that includes strings, lists and tuples. We'll start off by looking at strings. In Python, strings are arrays of bytes representing Unicode characters. When you're using strings, you put them either in a single quote, a double quote or a triple quote. I call them apostrophes. It's just what I was raised to call them but most people who use Python call them quotes. So right here, we have a single quote and that works well. We can do a double quote and that works also. And as you can see, they are the exact same output. And then we have a triple quote just like this and this is called a multi-line. So we can write on multiple lines here. So let's write a nice little poem. So we'll say, the ice cream, vanquished, my longing for sweets. Upon this diet, I look away. It no longer exists on this day. And then if we run that, it's gonna look a little bit weird. It's basically giving us the raw text, which is completely fine. But let's call this a multi-line. And we're gonna call this a variable multi-line. And we're gonna come down here and say print. And before I run this, I have to make sure that this is ran. So now let's print out our multi-line. And now we have our nice little poem right down here. Now something to know about these single and double quotes is how they're actually used. So if we use a single quote and we say, I've always wanted to eat a gallon of ice cream. And then we do an apostrophe at the end. Obviously something went wrong here. What went wrong is when you use a single quote and then within your text, within your sentence, you have another apostrophe. It's gonna give you an error. So what we wanna do is whenever we have a quote within it, we need to use a double quote. These double quotes will negate any single quotes that you have within your statement. They won't, however, negate another double quote. So you need to make sure you aren't using double quotes within your sentence. If you wanna do something like that, you need to use the triple quotes like we did above. So we can do double, double. And then let's paste this within it. And anything you do within these triple quotes will be completely fine as long as you don't do triple quotes within your triple quotes. And we'll say this is wrong. So even though it's between these two triple quotes, it doesn't work exactly. Again, you just have to understand how that works. You have to use the proper apostrophes or quotes within your string. And just to check this, we can always say, here's our multi-line. We can always say type of multi-line. And that is still a string. One really important thing to know about strings is that they can be indexed. Indexing means that you can search within it and that index starts at zero. So let's go ahead and create a variable. And we'll just say A is equal to, and let's do the all-popular hello world. Let's run this. And now when we print the string, we can say A and we're gonna do a bracket. And now we can search throughout our string using the index. So all you have to do is do a colon. We can say five. What this is gonna do is gonna say zero, position zero all the way up to five, which should give us the whole hello, I believe. Let's run this. And it's giving us the first five positions of this string. We can also get rid of the colon and just say something like five. And then when we run this, it's actually going to give us position five. So this is zero, one, two, three, four, and then five is the space. Let's do six so we can see the actual letter and that is our W. We can also use a negative when we're indexing through our string. So we could say negative three and it'll give us the L because it's negative one, two, and three. We can also specify a range if we don't want to use the default of zero. So before we did zero to five and it started at zero because that was our default but we could also do two to five. Let's run this. And now we go position zero, one, and then we start at two, L, L, O. Now we can also multiply strings and we have this A hello world. So we can do A times three. And if we run this, it'll give us hello world three times. And we can also do A plus A and that is hello world, hello world. Now let's go down here and take a look at lists. Lists are really fantastic because they store multiple values. The string was stored as one value multiple characters but a list can store multiple separate values. So let's create our very first list. We'll say list really quickly. And then we'll put a bracket and a bracket means this is going to be a list. There are other ones like a squiggly bracket and a parentheses. These denote that they are different types of data types. The bracket is what makes a list a list. So to keep it super simple, we'll say one, two, three and we'll run this. And now we have a list that has three separate values in it. The comment in our list denotes that they are separate values and a list is indexed just like a string is indexed. So position zero is this one, position one is the two and position two is the three. Now when we made this list we didn't have to use any quotes because these are numbers but if we wanted to create a list and we wanted to add string values we have to do it with our quotes. So we'll say quote cookie dough and then we'll do a comment to separate the value and then we'll say strawberry and then we'll do one more and this will just be chocolate. And when we run this we have all three of these values stored in our list. Now one of the best things about lists is you can have any data type within them. They don't just have to be numbers or strings you can basically put anything you want in there. So let's create a new list and let's say vanilla and then we'll do three and then we'll add a list within a list and we'll say scoops comma spoon and then we'll get out of that list and then we'll add another value of true for Boolean. And now we can hit shift enter and we just created a list with several different data types within one list. Now let's take this one list right here with all of our different ice cream flavors. We'll say ice underscore cream is equal to this list. Now one thing that's really great about lists is that they are changeable. That means we can change the data in here we can also add and remove items from the list after we've already created it. So let's go and take ice cream and we'll say ice cream dot append and this is gonna do append it to the very end of the list. We'll do an open parentheses and let's say salted caramel. Now when we run this and we call it just like this it's gonna take this list add salted caramel to the end and we'll print it off and as you can see it was added to the list and just like I said before, let me go down here we can also change things from this list. So let's say ice cream and then we need to look at the indexed position. So we're gonna say zero and that's gonna be this cookie dough right here. We can say that is equal to so we can now change that value. So let's call that butter pecan and now when we call it we can now see that the cookie dough was changed to butter pecan. Another thing that you saw just a little bit ago is something called a list within a list basically a nested list. So we had scoops spoon true. Let's give this and we'll say nested underscore list is equal to. Now when we run this we now have this nested list. So if we look at the index and we say zero we'll get vanilla. If we say two we'll get scoops and spoons. Now since we have a list within a list we can also look at the index of that nested list. So let's now say one and that should give us just spoon and you can go on and on and on with this. You can do lists within lists within lists and all of them will have indexing that you can call. Now let's go down here and start taking a look at tuples. So a list and a tuple are actually quite similar but the biggest difference between a list and a tuple is that a tuple is something called immutable. It means it cannot be modified or changed after it's created. Let's go right up here. We're gonna say tuple and let's write our very first tuple. So we'll say tuple underscore scoops is equal to and then we'll do an open parentheses. Now these open parentheses you've seen if you do like a print statement but that's different because that's executing a function. This is actually creating a tuple which is gonna store data for us. So we'll say one, two, three, two and one. Let's go ahead and create that tuple and we can just check the data type really quickly and it's a tuple. And just like we saw before, a tuple is also indexed. So if we go at the very first position which is a one we will get the output of a one but we can't do something like append and then add a value like three. If we do that it's gonna say tuple object has no attribute append. It's just because you cannot change or add anything to a tuple just like we were talking about before. Typically people will use tuples for when data is never going to change. An example for this might be something like a city name, a country, a location, something that won't change. They definitely have their use cases but I don't think they're as popular as just using a list. So now let's scroll down and start taking a look at sets but really quickly let me add a few more cells for us and let's say sets. Now a set is somewhat similar to a list and a tuple but they are a little bit different in fact that they don't have any duplicate elements. Another big difference is that the values within a set cannot be accessed using an index because it doesn't have an index because it's actually unordered. We can still loop through the items in a set with something like a for loop but we can't access it using the bracket and then accessing its index point. So let's go ahead and create our very first set. So we're gonna say daily underscore pints. Then we're gonna say equal to, and to create a set we're gonna use these squiggly brackets. I don't know if there's an actual name for those if I'm being honest. I call them squiggly brackets and that's what we're gonna go with. We're gonna put in a one, a two, and a three. So let's go ahead and run this and let's look at the type and as you can see it is a set. Now when we print this out it's gonna show us one, a two, and a three and those are all the values within our set but if we copy this and we'll say daily pints log this is gonna be every single day. Maybe I had different values. Now when we run this and we do the exact same thing now when we print this it's gonna have just the unique values within that set. Now a use case for set and this is something that I've done in the past is comparing two separate sets. Maybe you have a list or a tuple and you convert that into a set and that will narrow it down to its unique values and then you can compare the unique values of one set to the unique values in another set and then we can see what's the same and what's different. So let's go down here and let's say wife's underscore daily and I'll just copy this right here. We'll say is equal to let's do our squiggly lines. Let's do one, two, let's do just random numbers. So now this is my daily log and this is my wife's daily log and now we can compare these values. So let's go right down here. Let's say print, we'll do my daily logs and then we'll do this bar right here and this is gonna show us the combined unique values. It's basically like putting them all in one set and then trimming it down to just the unique values. So we'll take wife's daily pints log and when we run this, we actually need to run this first. When we run this, we should see all the unique values between these two sets. And so as you can see, zero, one, two, three, four, five, six, seven, 24, 31. So these are all the unique values between these two sets. We can also do another one. And instead of this bar, we're gonna do this symbol right here, which I believe is called an ampersand. Don't quote me on that. But when we run this, it's gonna show what matches. That means which ones show up in both sets. So the only ones that show up in both sets are one, two, three and five. We can also do the opposite of that by doing a minus sign. And this is gonna show us what doesn't match. So we have four, six and 31. Now where is our 24 that was in our wife's daily pints log? It's in this one, but we're subtracting the values on this one. So let's reverse this and we'll say daily pints log and let's run it. Now those are our other values. So we're taking the values of this and then we're subtracting all the ones that are the same and getting the remaining values. And then for our last one, we can get rid of this and we'll do this symbol right here. And this is gonna show if a value is either in one or the other, but not in both. So let's run this. So these values are completely unique only to each of those sets. Now the very last one that we are gonna look at in this video is dictionaries. So let's go right down here. Let's add a few cells and let's say dictionaries. Now I saved dictionary for last because this one is probably the most different out of all the previous data types that we've looked at. Within a data type, we have something called a key value pair. That means when we use a dictionary, it's not like a list where you just have a value, comma, value, comma, value. We have a key that indicates what that value is attributed to. So let's write out a dictionary to see how this looks. So we're gonna say dictionary underscore cream. And just like a set, we use a squiggly line. But the thing that differentiates it is that in a dictionary, we'll have that key value pair. Whereas in a set, each value is just separated by a comma. So let's write name and this is our key. And then we do a colon and this is then where we input our value. So we're gonna say Alex Freeberg. And then we separate that key value pair by a comma and now we can do another key value pair. So we'll say weekly intake and a colon and we'll say five pints of ice cream, the comma and then we'll do favorite ice creams. And now what we're gonna do is we're gonna put in here a list. So within this dictionary, we can also add a list. We'll do MCC from Mint Chocolate Chip and then we'll add chocolate, another one of my favorites. So now we have our very first dictionary. Let's copy this and run it. And let's just look at the type. And as you can see, it says that this is a dictionary. Let's also print it out. Now if we want to, we can take our dictionary cream and say dot values with an open parentheses. When we execute this, we'll see all of the values within this dictionary. So here's our values of Alex Freeberg, five Mint Chocolate Chip and chocolate. We can also say keys. And when we run this, all of the keys, the name, weekly intake and favorite ice creams. And we can also say items. So this key value pair is one item and this key value pair is another item. Now, one difference between something like a list and a dictionary is how you call the index. But you can't call it by doing something like this where you just do a bracket and say zero. So this would in theory, take this very first one, right? Our very first key value pair. That's gonna give us an error. How you call a dictionary is actually by the key. So it doesn't technically have an index, but you can specify what you wanna call and take it out. So we're gonna say name. And this is gonna call that key right here. And when we run this, we'll get the value, which is Alex Freeberg. One other thing that you can do is you can also update information in a dictionary, which we can't with some other data types. So for this, for the name, it was Alex Freeberg. Now let's say, Christine Freeberg. And when we update that, I'm also going to print the dictionary, get rid of this. So it's gonna update Christine Freeberg in that value of the name. So let's go ahead and run this. And now it changed the name from Alex Freeberg to Christine Freeberg. We can also update all of these values at one time. So let's copy this. And I'm gonna put it right down here. I'm gonna say dictionary.cream.update. Then we're gonna put a bracket or not a bracket, but a parentheses around these. So now what we're gonna do is update this entire thing. Let me take this, say print this dictionary. Now we can update this to anything we want. So instead of here, I can say, I'll say wait. And because of all that ice cream, I now weigh 300 pounds. So let's run this. And as you can see, it did not delete our key value pair right here. Instead it just added to it. When you're using the update, we can't actually delete. That's the delete statement and I'll show you that in just a second. But all we did was added this new value. It also was gonna check and see if you changed anything with your key value pair. So we can go in here and change this value and we'll say 10. So now when we run this, the value of this key value pair was changed. But let's say we do wanna delete it. We'll say DEL, that stands for delete. Part of this dictionary cream. And now let's specify the key which will also delete the value with it. Well, let's specify the key that we wanna get rid of and let's say wait. And then let's print that again. And as you can see, the wait was deleted from that dictionary. So that is all we're gonna cover in this data types video. Thank you guys so much for watching. I really appreciate it. If you liked this video, be sure to like and subscribe below and I'll see you in the next video.