 Hello, everybody. Today we're going to be learning about variables in Python. A variable is basically just a container for storing data values. So you'll take a value like a number or a string and you can assign it to a variable and then the variable will carry and contain whatever you put into it. So for example, let's go right over here. We're going to say X and this is going to be our variable. I'm going to say is equal to now we can assign the value to it. So let's say I want to put 22. X is now equal to 22. So we won't have to write out the number 22 in later scripts that we write. We can just say X because X is equal to 22. It now contains that number. So now we can hit enter and say print. We'll do an open parentheses and we'll say X. Now I'm going to hit shift enter and now it prints out that 22 because we are printing X and X is equal to 22. This is our value and this is our variable. One really great thing about variables is that it assigns its own data type. It's going to automatically do this. So we didn't have to go and tell X that it's an integer. It just automatically knew that 22 is a number. So we can check that by saying type and then open parentheses and writing X and we'll do shift enter again. And this says that X is an integer type. Now we only assigned an integer to X. Let's try assigning a string value or some text to a variable. So we'll say Y is equal to let's say mint chocolate chip. I'm feeling some ice cream today. So we'll say mint chocolate chip. Now if we print that again, we'll do print open parentheses Y and do shift enter. It'll print mint chocolate chip. And if we look at the type, we can see that the type is a string this time and not an integer. Now again, we did not tell it that X was an integer and Y was a string. It just automatically knew this. Let's go up here really quickly. We're going to add several rows in here because we're about to write a lot of different variables and really learn in depth how to use variables. The next thing to know about variables is that you can overwrite previous variables. Right now we have mint chocolate chip and that is assigned to the variable Y. So if I go down here, I say print Y and I hit shift enter. It's going to print out mint chocolate chip. But if I go right above it, I say Y is equal to and let's say chocolate. If I print that out, it's now going to say chocolate. Whereas up here, I'm reassigning it to Y. It's still going to say mint chocolate chip. So if I come right down here and I copy this and I'm going to paste this right here, initially it is going to assign Y to chocolate. But then right here, it will automatically overwrite Y as mint chocolate chip. And when we hit shift enter, it's going to show mint chocolate chip. Variables are also case sensitive. So if I come up here and I say a capital Y, this is a lowercase Y and this is a capital Y, it is going to print out the correct one instead of mint chocolate chip. And then if I go down here to the print and I type the capital Y, it will give us the mint chocolate chip. Up till now, we've only assigned one value to one variable, but we can actually assign multiple values to multiple variables. So let's do X comma Y comma Z is equal to. And now we can assign multiple values to all of those. So we can say chocolate and then we'll do a comma. Oops. A comma. Then we can say vanilla and then we'll do another comma and we'll say rocky road. Now this is going to assign chocolate to X, vanilla to Y and rocky road to Z. So what we can do is we'll say print and we'll go print, print, print. We'll say X, Y and Z. So it prints out chocolate, vanilla and rocky road. And these are our three different values. We can also assign multiple variables to one value. And we can do this by saying X is equal to Y is equal to Z is equal to. And we can put whatever we would like. Let's do root beer bloat. Then we'll come back up here. We'll copy this and let's print off our X, our Y and Z. And they are all the exact same. Now, so far we've really only looked at integers and strings, but you can assign things like lists, dictionaries, tuples and sets, all to variables as well. So let's go right down here. So let's create our very first list. I'm going to say ice underscore cream is equal to and that is our variable right there. The ice underscore cream is our variable. So now we're going to do an open bracket like this and we're going to come up here and copy all of these values and we're going to stick it within our list. So now within ice cream, we have three string values. Chocolate, vanilla and Rocky Road, all within this list. So what we can do is we can say X comma Y comma Z is equal to ice underscore cream. So now these three values, chocolate, vanilla and Rocky Road will be assigned to these three variables X, Y and Z. And we can copy this print up here and we'll hit shift, enter. And now the X, Y and Z all were assigned these values of chocolate, vanilla and Rocky Road. Now, something that we just do, which is really important or something that you really need to consider is how you name your variables. So right here, we have ice cream. Now, this to me is exactly how I usually write my variables, but there are many different ways that you can write your variable. So let's take a look at that really quickly and let's add just a few more because I have a feeling we're going to go a little bit longer than what we have. So there are a few best practices for naming variables. First, I'm going to show you kind of what a lot of people will do. I'll show you some good practices and I'm going to show you some bad practices as well that you should avoid doing. The first thing that we're going to look at is something called camel case. And let's say we want to name it test variable case. Oops, case. Now, if we have a test variable case, the camel case is going to look like this. We'll have a lower case test and then we'll have uppercase variable and uppercase case is equal to this is what this variable is going to look like. And we can assign it a nil a swirl. And this is what your camel case will look like. It's going to be lowercase and then all the rest of those compound words or however you want to say that, these letters are going to be capitalized to kind of separate where the words end and begin. Let's go right down here. We're going to copy this. The next one is called Pascal case. So Pascal case is going to look just a little bit different. Instead of the lowercase at test, it's going to be a capital T in test. So test variable case. Again, this is a very similar way of writing it, very similar to camel case, but just a capital at the beginning. Now let's look at the last one. And this one is my personal favorite. This one is going to be the snake case. Now, this one is quite a bit different in the fact that you don't use any capital letters and you separate everything using underscore. So we're going to write test underscore variable underscore case. Now, typically, let me have them all in there. Typically, these are the best practices. These are what you typically want to do, but probably the best one to use is this snake case right here. What a lot of people say is that it improves readability. If you take a look at either the camel case or the Pascal case, which you will see people do is not as easy to distinguish exactly what it says. And the name of a variable is important because you can gain information from it if people name them appropriately. So when I'm naming variables, I usually write it in snake case because I just find it a lot easier to read because each word is broken up by this underscore. So now let's look at some good variable names. These are all ones that you can use or could use. Let's do something like test var. So test var is completely appropriate. We can also do something like test underscore var. Oops, underscore. We could do underscore test underscore var. You'll see that often as well. Well, people will start it with an underscore. You can do test var capital T, capital T, capital V in test var. Or you could even do something like test var two. Now, adding a number to your variable is not inherently a bad thing. Usually it's semi frowned upon, but there are definitely some use cases where you can use it. But one thing that you cannot do is do something like. Putting the two at the front. If you put the two at the front, it no longer works. It won't run properly at all. So we're going to take that out so we can't do that. So I'm going to use this as an example of what you should not do. You also can't use a dash. So something like test dash var two, that doesn't work either. And you also can't use something like a space. Or a comma or really any kind of symbol like a period or a backslash or equal sign. None of those things will work within your variable. Now, another thing that you can do within your variable is use the plus sign. So let's assign this will say X is equal to and we'll do a string. We'll say ice cream is my favorite. And then we'll do a plus sign and we'll say period. Now, what this will do is it will literally add these two strings together. So let's do print and we'll do X. So now it says ice cream is my favorite. One thing that we cannot do in a variable is we cannot add a string and a number or an integer so we can't do ice cream as my favorite to if we try to do that. It will give us this error right here. So in this error, it's saying you can only concatenate a string, not an integer to a string. So only a string plus a string for this example, you can also do and we'll say X is equal to or we'll say why we'll say why is equal to. Three plus two and it should output five because you can also do an integer and an integer. Now, so far we've only been outputting one variable in the print statement, but you can actually add multiple variables within a print statement. So let's go right down here. We're going to say, let's get some more right there. So we'll say X is equal to ice cream and we'll say why is equal to. Is and then the last one Z is equal to my favorite and we'll do a period at the end. Now we can go to the bottom and we say print X plus Y plus C and when we enter that and when we run and when we run that, we get ice cream is my favorite. Now we can actually add a space before is a space before my and when we hit shift enter, it says ice cream is my favorite. You can also do this exact same thing with numbers as well. So we'll say X is equal to one, two, and Y is equal to three. So this should equal six. Now one thing that we tried to do was assign to one variable a string plus an integer and that did not work, but what you can do is you can take something like this and you can say ice cream and we'll get rid of this one and we'll get rid of the Z now saying plus is actually not going to work. Let's try running this. So again, we can't concatenate these, but what we can do in the print statement is we can separate it by a comma. So when we add this comma, it should work properly. Let's hit enter and it says ice cream to again, this makes no sense, but you are able to combine a string and an integer separating by a comma. Now this is the meat and potatoes of variables. There are some other things as well, but some of those things are a little bit more advanced and not something I wanted to cover in this tutorial, although we may be looking at some of those things in future tutorials, but this is definitely the basics. What you really, really need to know about variables. I hope that this video was helpful. If it was, be sure to like and subscribe below and I will see you in the next video.