1 00:00:00,000 --> 00:00:00,360 2 00:00:00,360 --> 00:00:03,290 >> SPEAKER 1: What if we only want Scratch to meow some of the time? 3 00:00:03,290 --> 00:00:04,790 That is conditionally. 4 00:00:04,790 --> 00:00:06,400 Well, let's write that program. 5 00:00:06,400 --> 00:00:09,730 Once again drag a when green flag clicked puzzle piece in to place. 6 00:00:09,730 --> 00:00:13,500 But this time, let's have a branch that only executes a block of code if 7 00:00:13,500 --> 00:00:14,870 something is true. 8 00:00:14,870 --> 00:00:18,810 >> Let's go to Control, drag in that branch. 9 00:00:18,810 --> 00:00:21,400 And now we have to decide on our Boolean expression. 10 00:00:21,400 --> 00:00:23,660 I only want him to meow some of the time. 11 00:00:23,660 --> 00:00:24,980 So how can I do that? 12 00:00:24,980 --> 00:00:28,590 >> Well, let's suppose that we can compare two numbers. 13 00:00:28,590 --> 00:00:29,780 Which we can in Scratch. 14 00:00:29,780 --> 00:00:31,170 Let's go to operators. 15 00:00:31,170 --> 00:00:35,340 Let's drag and drop into place this less than symbol as my Boolean 16 00:00:35,340 --> 00:00:36,290 expression. 17 00:00:36,290 --> 00:00:40,500 And let's now choose a random number, as by dropping pick random 18 00:00:40,500 --> 00:00:41,650 number from one to 10. 19 00:00:41,650 --> 00:00:44,185 And place that as our first operand. 20 00:00:44,185 --> 00:00:45,540 >> And less than-- 21 00:00:45,540 --> 00:00:48,490 well, I'd like him to meow 50% of the time. 22 00:00:48,490 --> 00:00:53,390 So after some thought, I think I'm going to put the number six into the 23 00:00:53,390 --> 00:00:54,480 right operand. 24 00:00:54,480 --> 00:00:58,600 There by asking the question, if my random number between 1 and 10 is less 25 00:00:58,600 --> 00:01:01,060 than six then do something. 26 00:01:01,060 --> 00:01:02,300 Well, what do I want him to do? 27 00:01:02,300 --> 00:01:06,900 >> Well, let's go to our sound pallet, drag in play sound meow. 28 00:01:06,900 --> 00:01:08,150 Lock that into place. 29 00:01:08,150 --> 00:01:11,320 And now let's click that green flag. 30 00:01:11,320 --> 00:01:12,350 No meow. 31 00:01:12,350 --> 00:01:14,050 But that's to be expected sometimes. 32 00:01:14,050 --> 00:01:16,090 >> Let's try again. 33 00:01:16,090 --> 00:01:17,140 Still no meow. 34 00:01:17,140 --> 00:01:18,810 But it could happen by chance. 35 00:01:18,810 --> 00:01:22,310 And a third time, still no meow. 36 00:01:22,310 --> 00:01:25,660 Better cross our fingers but keep trying. 37 00:01:25,660 --> 00:01:29,640 Four times, those are some odds. 38 00:01:29,640 --> 00:01:33,320 Five times, this is very unlikely. 39 00:01:33,320 --> 00:01:34,120 Meow. 40 00:01:34,120 --> 00:01:34,940 Thank god. 41 00:01:34,940 --> 00:01:37,550 >> And on the six time, it's the charm. 42 00:01:37,550 --> 00:01:41,060 Let's try it a seventh time and tempt fate. 43 00:01:41,060 --> 00:01:43,350 And an 8th time. 44 00:01:43,350 --> 00:01:46,100 And a ninth time-- meow. 45 00:01:46,100 --> 00:01:47,410 There you have it. 46 00:01:47,410 --> 00:01:49,420 50% probability of Scratch meowing. 47 00:01:49,420 --> 00:01:51,525