>> SPEAKER 1: What if we only want Scratch to meow some of the time?
That is conditionally.
Well, let's write that program.
Once again drag a when green flag clicked puzzle piece in to place.
But this time, let's have a branch that only executes a block of code if
something is true.
>> Let's go to Control, drag in that branch.
And now we have to decide on our Boolean expression.
I only want him to meow some of the time.
So how can I do that?
>> Well, let's suppose that we can compare two numbers.
Which we can in Scratch.
Let's go to operators.
Let's drag and drop into place this less than symbol as my Boolean
expression.
And let's now choose a random number, as by dropping pick random
number from one to 10.
And place that as our first operand.
>> And less than--
well, I'd like him to meow 50% of the time.
So after some thought, I think I'm going to put the number six into the
right operand.
There by asking the question, if my random number between 1 and 10 is less
than six then do something.
Well, what do I want him to do?
>> Well, let's go to our sound pallet, drag in play sound meow.
Lock that into place.
And now let's click that green flag.
No meow.
But that's to be expected sometimes.
>> Let's try again.
Still no meow.
But it could happen by chance.
And a third time, still no meow.
Better cross our fingers but keep trying.
Four times, those are some odds.
Five times, this is very unlikely.
Meow.
Thank god.
>> And on the six time, it's the charm.
Let's try it a seventh time and tempt fate.
And an 8th time.
And a ninth time-- meow.
There you have it.
50% probability of Scratch meowing.