0:00:01.083,0:00:03.846 So I've got my good friend Winston here[br]to help us out with this one. 0:00:03.846,0:00:06.424 And I know he already looks[br]impossibly awesome, 0:00:06.424,0:00:08.911 but I think I want to change[br]his eye size a little bit. 0:00:08.911,0:00:10.784 So here is where I draw his eyes. 0:00:10.784,0:00:13.343 You can see we set the fill color,[br]and then drop two ellipses. 0:00:13.343,0:00:15.273 And if I want to make[br]this ellipse smaller, 0:00:15.273,0:00:18.011 I can change the width,[br]but then I also want it to be round, 0:00:18.011,0:00:20.284 so I'm going to change the height[br]to be the same thing. 0:00:20.284,0:00:22.955 And, well I want the eyes[br]to be the same size, 0:00:22.955,0:00:25.381 so we should change the width[br]and the height of this eye. 0:00:25.381,0:00:28.497 No, now the eyes are a little too small,[br]so I should change them back. 0:00:28.707,0:00:30.839 Wouldn't I be great if I could[br]just change one number, 0:00:30.839,0:00:32.656 and have both eyes change? 0:00:32.877,0:00:36.191 And here is where variables come in. 0:00:37.232,0:00:40.848 Now, a variable is just like a name[br]or a placeholder for something else. 0:00:41.303,0:00:44.523 I like to think of a variable[br]as a big bucket with a name on it. 0:00:44.566,0:00:46.295 You can put anything[br]you want in the bucket, 0:00:46.295,0:00:47.588 but the name stays the same. 0:00:47.747,0:00:51.937 We call the thing inside the bucket[br]the value of the variable. 0:00:53.702,0:00:55.745 So let's start out by actually[br]making a variable. 0:00:55.745,0:00:57.564 I'm going to do it all the way up here. 0:00:57.564,0:01:00.333 All you do is type var,[br]which stands for variable, 0:01:00.333,0:01:02.477 Space, and then[br]the name of the variable, 0:01:02.477,0:01:04.465 which should describe[br]what the variable will hold. 0:01:04.465,0:01:06.007 So I'm going to call this one eyeSize. 0:01:06.007,0:01:07.997 And you can pretty much[br]name it whatever you want, 0:01:07.997,0:01:10.043 but you're not allowed to have[br]spaces between words. 0:01:10.043,0:01:11.974 And of course,[br]don't forget that semicolon! 0:01:12.248,0:01:14.447 So now I've made[br]a variable called eyeSize, 0:01:14.447,0:01:16.936 because it's going to hold[br]the size of Winston's eyes. 0:01:16.936,0:01:19.511 But so far this variable[br]doesn't have a value yet. 0:01:19.846,0:01:22.642 To give it one, we just say eyeSize, 0:01:22.642,0:01:27.186 and then an =, and then 20; . 0:01:27.611,0:01:29.370 Okay, now see that equal sign? 0:01:29.370,0:01:31.763 Forget whatever your math teacher[br]taught you about it. 0:01:31.763,0:01:35.086 That equal sign does not mean "equals,"[br]it means assignment. 0:01:35.391,0:01:41.264 This means we're assigning[br]the value 20 to the variable eyeSize. 0:01:42.014,0:01:43.716 In other words,[br]we're putting the number 20 0:01:43.716,0:01:45.576 into the bucket called, eyeSize. 0:01:45.728,0:01:48.438 And remember how in math class[br]you can say stuff like, 0:01:48.438,0:01:51.818 x = 3, and 3 = x, 0:01:51.818,0:01:54.457 and it all means the same thing,[br]because duuh, they're equal? 0:01:54.457,0:01:56.377 Well, you can't do that here, either. 0:01:56.377,0:01:58.443 The thing on the left-hand side[br]of the equal sign 0:01:58.443,0:01:59.985 is always the variable. 0:01:59.985,0:02:03.397 And the thing on the right-hand side[br]of the equal sign is always the value 0:02:03.397,0:02:05.331 that you are assigning to the variable. 0:02:05.501,0:02:07.549 A good way to help you[br]remember which side is what 0:02:07.549,0:02:09.790 is while you're coding[br]and talking out loud to yourself, 0:02:09.790,0:02:11.491 like every cool programmer does, 0:02:11.491,0:02:15.290 if you hit an equal sign[br]don't say "equals," say "gets." 0:02:15.290,0:02:18.587 So this becomes, eyeSize gets 20. 0:02:19.619,0:02:22.049 And now, whenever I use[br]eyeSize in my program, 0:02:22.049,0:02:24.780 the computer is going to be like,[br]"Oh yeah, that's a variable, 0:02:24.780,0:02:27.871 I know what she really means[br]is this value 20." 0:02:28.312,0:02:31.131 So check it out--[br]I'm just going to copy this, 0:02:31.419,0:02:34.405 and then replace these four numbers 0:02:34.785,0:02:37.058 with my new variable eyeSize, 0:02:38.255,0:02:39.614 and Voila! 0:02:39.614,0:02:43.920 Winston's eyes are now both[br]perfectly round and the same size, 0:02:43.920,0:02:46.591 and if I want to change[br]the value of both eyes-- 0:02:46.591,0:02:47.730 or the size of both eyes, 0:02:47.730,0:02:50.547 I can just change the value[br]of this one variable. 0:02:51.002,0:02:53.045 Aah that's so cool! 0:02:54.309,0:02:55.667 Okay, couple of last notes. 0:02:55.667,0:02:58.512 Up here we made[br]a new variable called eyeSize. 0:02:58.512,0:03:01.037 And here we gave it a value of 33. 0:03:01.037,0:03:02.855 We can actually do that all in one step 0:03:02.855,0:03:05.927 by saying var eyeSize,[br]that's the first step, 0:03:05.927,0:03:08.717 gets 33,[br]that's the second step. 0:03:08.717,0:03:10.825 And if I delete these two lines, 0:03:10.825,0:03:12.626 you can see everything still works. 0:03:13.449,0:03:16.761 Also remember that the computer[br]reads your code from top to bottom 0:03:16.761,0:03:19.188 so the only reason it knew[br]what eyeSize was down here, 0:03:19.188,0:03:21.668 was because we already[br]defined it up here. 0:03:21.668,0:03:24.309 If I had put it down here instead, 0:03:25.021,0:03:28.446 then once we got to this line of code,[br]the computer's going to be like, 0:03:28.446,0:03:30.989 "eyeSize, what the heck is eyeSize?[br]I don't know what that is." 0:03:30.989,0:03:34.002 In fact, here we get an error that says[br]eyeSize is not defined. 0:03:34.002,0:03:35.570 And maybe you're thinking to yourself, 0:03:35.570,0:03:37.481 "Yes, I did define it; it's right here!" 0:03:37.481,0:03:39.584 But the computer's not smart,[br]and doesn't get that. 0:03:40.406,0:03:42.636 So let's just move it back up to the top. 0:03:44.029,0:03:45.549 And you've got to always make sure 0:03:45.549,0:03:48.259 that you define your variable[br]before you try to use it. 0:03:49.137,0:03:51.911 And now you know[br]about variables! Yaaay!