00:05In Python we were able to store text, or to output text using the print function, so anything
00:11we gave to the print function is output to the screen.
00:14So this could be either just text, or it can be numbers, or even mathematics.
00:26So you can say, for example, 2 times 3 times 4, and it outputs the result.
00:34So print lets you show data on the screen, but of course at some point you want to store
00:38data.
00:39For example, if you want to define a name, say you want to store a first name, last name,
00:50and such kind of information, you can do so by typing the is symbol, and then defining
00:57your data.
00:58So for example, you can store data like this.
01:09And you can use the print function to output, for example, first name, last name.
01:15And if you run it, you see it outputs that text.
01:19Now this works for different types of data, for example, it doesn't have to be just text.
01:24You can define numbers, and output those.
01:33Now, you can also use dot behind the value.
01:41And you can add them together in a new variable, for example, set is x plus y.
01:47And output that, so you'll see it does the math here when defining z, but you can define
01:55numbers, so you can define different things.
01:59And you can also get it from the user.
02:02For example, you can use the input function, and then output it.
02:09So now it would do keyboard output.
02:11If you use a very old version of python, so you'll see I'm using python3 here.
02:19If you're still using python2 because that's installed on your system, you had to use raw input
02:24instead.
02:25But any modern version of python, python3 and newer, you have the input function.
02:31So if I run this, let me just clear the screen.
02:34If I run this, you'll see it asks for your name.
02:37Then it stores that keyboard input into the variable name, and it outputs that.
02:44And you can get input anything you want.
02:48So for example, let's ask something else.
02:57Output it.
02:59You'll see now it asks for your name, and your job.
03:03And it stores both of them in the variables name and job.
03:09So that's what variables is, it's just a way to store data in the computer.
03:12And these variables exist only when running your program.
03:17So when you stop the program, those variables don't exist anymore.
03:20They only exist while your program is running.
03:23And let's just store different data.
03:24So you can store text, so whatever text you want, you can store numbers.
03:34And you can also store a so-called boolean, which is like a light switch, either true or
03:38false.
03:40So for example, a button can either be on or off.
03:45So off and on.
03:48So those are different rules that Python supports.
03:57We can do a bit more fancy output by using so-called f-strings, or f-out functional strings.
04:03Which you do by typing f in the print function, then the quotes, and then you can type your
04:09variables.
04:12So that would output them to the screen.
04:15You'll see, let me just clear here.
04:18I run it, I type the data, and you'll see it outputs them to the screen.
04:24And you can mix this with text.
04:26So for example, my name is name, and my job is job.
04:33And then if you run it, you'll see it adds those variables to text.
04:41This works for any input, right?
04:43So if we run it again, and maybe type something else, you'll see that it changes that data where
04:54the variables were.
04:57Now Python also supports list variables, which is like a collection.
05:02So we can say names is, and then a list of names, or perhaps rows.
05:10It doesn't really matter what's inside the data.
05:14List can be of any length.
05:18And you can output them.
05:22So let me clear the screen again here.
05:25You'll see it outputs the data of the list.
05:30If you want a single item of that list, you can use these square brackets, and then type
05:35a number.
05:36Zero would be the first item.
05:38So zero, in this case, would be Batman, because computers start counting from zero.
05:42So humans would say this is the first item, but computers would say this is the zeroed
05:47item.
05:48So if we type zero, you'll see it shows the first item.
05:52One would show the second item of the list.
05:55And Python knows it's a list because you're using those square brackets.
05:59So that's a very important distinction, that when you use those square brackets, Python
06:05immediately understands that it is a list.
06:10So if you want to be sure about which type of variable you have, you can do print, type,
06:16and then your variable name.
06:18So for example, if we type heroes, you'll see Python returns that it is a list.
06:26If we define some other variable, let's say name, and then output the type.
06:35Run it again.
06:37You'll see it outputs str here, which starts for string.
06:40Now string in Python is just text, it's just another name for text.
06:44You can say, let's say x is 3, output the type of x, and show it.
06:51You'll see it outputs pins here.
06:55So Python automatically knows the type of your variable, depending on what you feed it.
07:02So here we say, we give it a list.
07:04Python knows because you use those brackets.
07:07Here it knows its text because you use those quotes, or string, and here it knows its number.
07:13Integer is a whole number, or natural number, 1, 2, 3, 4, and so on.
07:18And Python knows it is an integer because you define it like that.
07:24So that's Python.
07:26And lists are dynamic, so you can do some fun things with lists.
07:30For example, you can say heroes.append, and then your own name, print the list.
07:41If we run it, and we look what's inside list, you'll see your own name appear.
07:46So you can use append to add something to the list.
07:50If you want to remove something, you can use the pop function.
07:54So pop removes an item from the list.
07:55You'll see it first calls pop, so it removes Spider-Man.
07:59And we use append and add our own name.
08:03And you'll see it added that.
08:05So lists are collections that you can use.
08:09If you want to store a lot of names or a lot of numbers, so you can also have a
08:14list of
08:15numbers.
08:19Whatever numbers you want.
08:21So it can be whatever numbers you want and the same principles apply.
08:28So those are the common variables in Python or the common ways to store data in Python.
08:35Python.
08:35So whenever you see dot dot dot is equal to something, you know that what's actually happening is
08:43that that data is stored into the variable.
08:46So these are all variables.
08:49And you know that if you see these square brackets, it's a list or a collection.
08:54If not, it can be just a number or text.
08:57So just text like this or just a single number.
09:01So that's what variables do.
09:02It just lets you store a program.
09:04Let's just let you store data for later use in the program.
09:07So whenever you have a variable, let's say name, you can output that as many times as you want.
09:14Or you can use it in your program to do whatever you want.
09:18So a variable lets you store data that you can use throughout your program as much as you
09:25want.
09:25Let's pause.
09:27So let's pause for another episode.
Comments