0:00:02.923,0:00:05.567 In the English language,[br]we have different parts of speech, 0:00:05.567,0:00:08.309 like noun, adjective, preposition, verb. 0:00:08.309,0:00:09.886 And then there are a bunch of rules 0:00:09.886,0:00:12.601 that tell us how to put[br]these different parts of speech together. 0:00:12.601,0:00:19.341 So if I said something like,[br]"Dog books my eats," 0:00:19.341,0:00:22.033 you'd be like,[br]"What the heck does that mean?" 0:00:22.033,0:00:23.913 And if you didn't realize this before, 0:00:23.913,0:00:25.867 apparently, you can't just stick[br]two nouns 0:00:25.867,0:00:28.108 in front of an adjective,[br]in front of a verb. 0:00:28.108,0:00:29.440 Doesn't work. 0:00:29.440,0:00:34.764 But if I'd switched those and said,[br]"My dog eats books," 0:00:34.764,0:00:37.260 then you would totally know what I meant. 0:00:37.260,0:00:38.910 I could even replace this verb "eats" 0:00:38.910,0:00:42.765 with another verb like,[br]I don't know, "throws", 0:00:42.765,0:00:45.426 and it would still make grammatical sense, 0:00:45.426,0:00:47.875 even if you can't imagine[br]my dog throwing a book. 0:00:47.875,0:00:49.991 So in programming,[br]instead of parts of speech, 0:00:49.991,0:00:52.125 we have these things called types. 0:00:52.125,0:00:54.485 You've already seen one of these: numbers. 0:00:54.485,0:00:57.067 We use numbers all the time[br]in our drawing code. 0:00:57.067,0:00:58.536 And just like in English, 0:00:58.536,0:01:01.802 there are times it makes sense to use[br]a number, and times when it doesn't. 0:01:01.802,0:01:06.104 If I started typing in[br]this background function, "100 minus", 0:01:06.104,0:01:08.696 then whatever comes next[br]better be a number, 0:01:08.696,0:01:13.508 or at least something that evaluates[br]to a number like "14 + 15." 0:01:13.508,0:01:17.833 On the other hand,[br]if I'd just typed "100 space", 0:01:17.833,0:01:20.434 well, I can't really put[br]a number after that 0:01:20.434,0:01:23.815 because "100-space-10"[br]doesn't mean anything. 0:01:23.815,0:01:27.534 So there's another type in programming,[br]called the Boolean type. 0:01:27.534,0:01:29.133 And it's called Boolean 0:01:29.133,0:01:33.631 because some dude[br]named George Boole invented it. 0:01:33.631,0:01:37.394 And unlike a number[br]which has a ton of possible values, 0:01:37.394,0:01:42.031 a Boolean can only be[br]one of two values: true or false. 0:01:43.000,0:01:44.932 And you can see[br]when I type them they turn blue, 0:01:44.932,0:01:47.333 which means they're[br]super special awesome words. 0:01:47.333,0:01:49.433 And you've already seen one place[br]where we use booleans, 0:01:49.433,0:01:52.036 though you may not have realized it:[br]if statements! 0:01:52.036,0:01:53.968 Let's get a quick refresh[br]on how those work. 0:01:53.968,0:01:58.931 I'm just going to make a variable[br]called 'number, ' give it a number, 40. 0:01:58.931,0:02:01.499 And write an If statement that says, 0:02:01.499,0:02:08.707 "If number is less than 50,[br]then I will draw this first ellipse." 0:02:10.795,0:02:13.044 I'm just going to copy this[br]into the If statement 0:02:13.044,0:02:16.234 and indent it by selecting everything[br]and pressing tab. 0:02:16.234,0:02:18.333 So now this statement says, 0:02:18.333,0:02:22.772 "If number is less than 50," which it is,[br]"then we'll draw the top ellipse." 0:02:22.772,0:02:25.431 And if I make number greater than 50, 0:02:25.431,0:02:28.434 you can see[br]that the top ellipse disappears. 0:02:28.434,0:02:30.573 Alright, so this thing[br]inside the parentheses 0:02:30.573,0:02:32.831 is actually a Boolean expression. 0:02:32.831,0:02:36.164 Remember, a math expression[br]is anything that evaluates to a number: 0:02:36.164,0:02:40.204 like 3 plus 2 plus 4 times 8. 0:02:40.204,0:02:43.801 So a Boolean expression is anything[br]that evaluates to a Boolean. 0:02:43.801,0:02:46.499 A good way to check[br]if an expression evaluates to a Boolean, 0:02:46.499,0:02:50.500 is to stick the word "is" in front of it,[br]and ask it like a question. 0:02:50.500,0:02:54.043 If it sounds like a yes or no question,[br]then you know it's a Boolean expression. 0:02:54.043,0:02:57.137 So here we can say,[br]"Is number less than 50?" 0:02:57.137,0:03:00.598 Yes, yes it is, and yes,[br]that is a Boolean expression. 0:03:00.598,0:03:04.173 On the other hand,[br]if I had something like, "4 + 4" 0:03:04.173,0:03:10.224 and I tried to ask, "is 4 + 4?"[br]No. not a Boolean. 0:03:10.224,0:03:12.065 So back to our If statement. 0:03:12.065,0:03:14.573 I can actually put anything[br]inside these parentheses, 0:03:14.573,0:03:17.457 as long as it's a Boolean[br]or Boolean expression. 0:03:17.457,0:03:21.289 So I could say, "If true,"[br]and that ellipse would always be drawn. 0:03:21.289,0:03:24.598 Or I could say, "If false,"[br]and the ellipse would never be drawn. 0:03:24.598,0:03:28.699 I could also do something like[br]"If 3 is less than 4," 0:03:28.699,0:03:32.035 which is a Boolean expression[br]that will always evaluate to true, 0:03:32.035,0:03:34.664 which is kinda pointless,[br]the ellipse will always be drawn, 0:03:34.664,0:03:38.042 or "3 greater than 4,"[br]and that's always going to be false. 0:03:38.042,0:03:41.049 And I can also assign Booleans[br]to variables, like this: 0:03:41.049,0:03:48.767 so I'm going to make a new variable,[br]call it WinstonIsCool, and assign it 0:03:48.767,0:03:51.500 a Boolean value, so true or false. 0:03:51.500,0:03:54.274 Say true because Winston[br]is definitely cool. 0:03:54.274,0:03:57.047 And now that this variable[br]has a Boolean value, 0:03:57.047,0:04:00.444 I can copy it and stick it[br]inside this If statement 0:04:00.444,0:04:04.120 and now you can see the ellipse is drawn, 0:04:04.120,0:04:06.731 because the value[br]of WinstonIsCool is true. 0:04:06.731,0:04:10.600 I could also replace this[br]with a Boolean expression, 0:04:10.600,0:04:14.200 so could be "2 less than 4." 0:04:14.200,0:04:18.099 Now if you're making a variable[br]that's meant for a Boolean value, 0:04:18.099,0:04:19.602 you should give it a name 0:04:19.602,0:04:21.997 that describes the condition[br]when the variable is true. 0:04:21.997,0:04:24.902 A good way to check if you've picked[br]a good name for your variable 0:04:24.902,0:04:28.330 is to put it in an If statement[br]and see if it makes sense as a condition. 0:04:28.330,0:04:31.434 So, forget WinstonIsCool,[br]we already know that's true. 0:04:31.434,0:04:34.306 Let's say I had a variable[br]called "muffins." 0:04:34.306,0:04:37.101 All right, "If muffins." Hmm. 0:04:37.101,0:04:38.304 Well, you know what? 0:04:38.304,0:04:42.169 That doesn't tell me anything,[br]so that's a pretty bad variable name, 0:04:42.169,0:04:46.166 but if I had "If muffinsAreBaking",[br]then that would tell me 0:04:46.166,0:04:50.931 that when this variable is true,[br]then the muffins are baking. 0:04:50.931,0:04:54.229 And don't ask me what muffins,[br]it's not important. 0:04:54.229,0:04:59.000 So for now let's go back[br]to "If number is less than 50." 0:04:59.000,0:05:00.383 Cool. 0:05:00.383,0:05:02.538 Now let's look[br]at some other Boolean expressions. 0:05:02.538,0:05:05.772 You've already seen[br]"less than" and "greater than", 0:05:05.772,0:05:09.077 but you can also check[br]if something is "less than or equal to." 0:05:09.077,0:05:12.571 So let's try, "If number is[br]less than or equal to 48." 0:05:12.571,0:05:20.034 And we could also say, "If number[br]is greater than or equal to 48." 0:05:20.034,0:05:24.201 If it is, we will draw[br]this top-right ellipse. 0:05:24.201,0:05:27.375 Indent that. 0:05:27.375,0:05:30.271 And if you'd like to check if two things[br]are exactly equal to each other 0:05:30.271,0:05:32.419 or you could say: "If number" 0:05:32.419,0:05:36.281 and then three equals signs,[br]or "triple equals 48." 0:05:39.494,0:05:42.496 So that's a lot more like the equals sign[br]you're used to in math, 0:05:42.496,0:05:44.794 except this time[br]you have three of them in a row. 0:05:44.794,0:05:46.634 It's kind of overkill, right? 0:05:46.634,0:05:48.899 And then finally, we have[br]if you want to check 0:05:48.899,0:05:51.235 if two things are not equal to, 0:05:51.235,0:05:53.236 so strictly not equal to, you can say, 0:05:53.236,0:05:57.601 "If number" and then an exclamation point,[br]and then 2 equals signs, "48". 0:05:57.601,0:06:02.134 And then we will draw that last ellipse. 0:06:04.096,0:06:07.499 So if we go back to the top,[br]we can see that number is 48, 0:06:07.499,0:06:09.765 so it is less than or equal to 48, 0:06:09.765,0:06:11.766 which is why[br]the top-left ellipse is drawn. 0:06:11.766,0:06:16.201 It's also greater than or equal to 48,[br]it's also equal to 48, 0:06:16.201,0:06:18.701 but it is not not equal to 48, 0:06:18.701,0:06:21.630 which is why we're missing[br]that bottom-right ellipse. 0:06:21.630,0:06:23.803 And if we play around with number 0:06:23.803,0:06:26.346 you can see it changes[br]which ellipses are drawn. 0:06:26.998,0:06:29.634 So now you guys know about Booleans. 0:06:29.634,0:06:31.300 And just like math expressions, 0:06:31.300,0:06:33.734 Boolean expressions[br]can get really complicated. 0:06:33.734,0:06:35.743 But we will talk about those another time.