WEBVTT 0 00:00.180 --> 00:03.220 Hey guys, welcome back to a new lecture. In this lecture 1 00:03.300 --> 00:09.980 we have to talk about variables but before that let us take an example of our earlier maths classes 2 00:10.170 --> 00:14.760 So when you were in 8th or 10th standard you have to solve a math problem. 3 00:14.760 --> 00:20.170 So you might have used x, y, z and you might have used 4 00:20.190 --> 00:20.960 p, q, r 5 00:21.090 --> 00:24.910 So we use some identifiers to solve our problems. 6 00:25.080 --> 00:32.430 Similarly we have to use variables to solve different type of problems and variables are really important 7 00:32.610 --> 00:34.370 to understand datatypes 8 00:34.380 --> 00:41.370 So before jumping onto any heavy word or before jumping and trying to do any big task you need to understand 9 00:41.460 --> 00:42.340 variables 10 00:42.480 --> 00:49.740 So in programming languages like C, Java or any other programming language the concept of variable is connected 11 00:49.740 --> 00:51.170 with memory location. 12 00:51.360 --> 00:56.460 So in other languages, a variable is imagined as store box 13 00:56.490 --> 00:58.430 So it is like a container 14 00:58.470 --> 01:00.710 So if I take an example of addition. 15 01:00.810 --> 01:03.230 Suppose I need to do 5 + 6 16 01:03.240 --> 01:10.560 So what I was doing like, 5 + 6 and then simply an enter but what if I take variable, store 17 01:10.560 --> 01:13.880 them into boxes and then try to perform. 18 01:13.890 --> 01:17.120 Let me take an example and make you more comfortable. 19 01:17.340 --> 01:26.640 So if I take x=5 and then y=6 and then I can try to perform addition with x and y. 20 01:26.720 --> 01:29.440 Now x has the value of 5. 21 01:29.570 --> 01:34.570 y has the value of 6 and I can try to perform addition between them. 22 01:34.880 --> 01:37.540 So here x and y are the variables. 23 01:37.760 --> 01:40.800 So there is a container which has a value of 5. 24 01:40.840 --> 01:45.500 we call it as x and there is a container which has a value of 6 25 01:45.500 --> 01:47.460 we call it as y 26 01:47.520 --> 01:54.870 Now you might be thinking if I take z and keep the value of z as 5. Z will be pointing towards the same 27 01:54.870 --> 01:57.580 container to which x is pointing 28 01:58.050 --> 02:00.760 Yeah, they will be pointing towards the same container. 29 02:00.780 --> 02:04.990 Let us perform this example also. Let me take z as 5 30 02:05.280 --> 02:10.540 And now let me try to get memory address of x and z, both of them. 31 02:10.560 --> 02:17.560 So I just need to type id and then here I need to give the value between the parentheses of the variable 32 02:17.590 --> 02:20.130 of which I need to find out the location. 33 02:20.130 --> 02:24.400 So if I give X you can see this is the memory location 34 02:24.540 --> 02:29.870 and if I try to do same thing for z, here you will get the same address 35 02:29.980 --> 02:34.580 and if I try to perform same thing with y you might see some different result 36 02:34.660 --> 02:36.450 So let us do that also. 37 02:37.680 --> 02:43.370 Here you can see x and z have same address whereas y has different address. 38 02:43.420 --> 02:50.420 Let me try to do one more thing, let us try to perform 2 + 3 and store it in some different variable 39 02:50.670 --> 02:52.880 and try to find out that address. 40 02:52.890 --> 02:59.290 So let me take example of p=2 and q=3 41 02:59.610 --> 03:05.460 And then we might try to do r = p + q and let us print r 42 03:05.730 --> 03:13.560 and now let's us check the address that is the memory address for r. Here you can see r, x and z all 43 03:13.560 --> 03:14.640 have same address. 44 03:14.640 --> 03:18.720 That means there is a container which stores the value of 5 45 03:18.930 --> 03:25.200 and if any variable have the same exact value it will point towards that particular container. 46 03:25.380 --> 03:29.350 I hope this point was clear because it is really important. 47 03:29.550 --> 03:36.010 This shows the efficiency of python because python is a memory efficient language. 48 03:36.070 --> 03:41.600 and now if I try to give a different value to z, what will happen to the memory location. 49 03:41.610 --> 03:47.630 So if I do z=7 here and then try to find out the memory location of z 50 03:47.720 --> 03:55.370 You will see a different address so that how memory location changes according to the value and the variables. 51 03:55.380 --> 03:57.950 I hope you understand this particular point. 52 03:57.990 --> 04:01.810 The next thing is if I directly want to find the address of 5 53 04:01.980 --> 04:05.050 So you can see how the memory location is allocated 54 04:05.190 --> 04:11.130 So this point was really important for you to understand the management of memory with python. In the 55 04:11.150 --> 04:11.800 next lecture 56 04:11.800 --> 04:15.040 We'll be talking about 'Data types' in Python.