# Lesson video

In progress...

Hello, welcome to this unit on selection in quizzes.

My name's Josh, I'm your computing teacher.

And in this lesson, we're going to look at exploring conditions.

So how conditions and selection is used within programmes.

If you're unsure about selection and programmes, it's recommended that you go back, and you complete the selection in physical computing unit before continuing with this one.

We are going to be using the Scratch programme today so make sure you've got access to a web browser.

If you don't have an account and you're under the age of 13, you will need your parent, carer, or teacher to help you set one up.

You don't absolutely need an account, so if you're going to continue without using an account that's fine, but do you make sure you are downloading any projects after tasks or after the lessons to ensure that you've got them to refer to in the future.

You are going to need something to write on and with, so make sure you have those to hand.

If you've got all of those bits ready, then we can make a move and crack on with the start of lesson one.

So at the end of this lesson, you will be able to explain how selection is used in a computer programme.

To get to that point, you are going to recall how conditions are used in selection.

You're going to identify conditions in a programme, and you're going to modify a condition in a programme.

The first thing we're going to look at is true or false.

In a moment, I'm going to show you a slide, and a number of statements are going to appear.

Now you need to decide whether that statement is true or false for you as an individual.

So it'd be different for different people, but this is about you so make a note of this as we go through as to whether or not this is true or false for you.

The first statement, today is Wednesday.

So I'll give you a few moments just to note down whether or not that's true or false for you.

I hope you've written that down.

The next one is my birthday is in March.

Take a few moments, note down whether that's true or false.

The next statement is I like carrots.

True or false, note that down.

The next one, my first name contains the letter S, note that down, true or false.

And finally it is raining, true or false? Note that down.

So hopefully you've noted down then all of those different answers.

What I'd like you to do is read this statement.

If you recorded more than two trues, then give a thumbs up to the screen.

If you recorded more than two trues, give a thumbs up to the screen.

I'm going to give you a thumbs up because I recorded more than two truths.

So why did you or why didn't you carry out that action? Just pause the video and I'd consider that question.

So why did you or why didn't you carry out that action? So pause the video now and resume when you're finished.

Welcome back, hopefully you've understood that the reason you did or didn't was based on that if statement there.

So that if statement that said if you recorded more than two truths and more than two, then give a thumbs up.

So if you've written down more than two trues, if you've said yes to more than two of those statements, then you should have given a thumbs up and if you didn't, then you didn't do that.

And it was all based on that if statement.

So we're going to look at a little bit more on that, and that is a fundamental part of our selection within programmes.

Now you should have used selection before in the selection of physical computing unit.

So you should have already used selection so you should be at least familiar with the construct.

So we're going to look a little bit more detail at that now.

We're going to move on to your first task.

Your first task is to open up that short link and it'll take you to a Scratch page.

Now if you have an account, you can remix that Scratch project and it will become what would become a remixed version, the copied version for yourself.

And you'll be able to edit that as much as you like, and it will save in your account.

If you don't have an account, that's fine.

Just make the changes or do the exploration on that project.

And then at the end of your task, you need to download that project so that you've got a copy of it.

So you're going to open up Scratch using that short link, and then I'd like you to read the questions on the worksheet and just go through them answering them as you go.

So pause the video, have a go at task one.

Welcome back then, hope you had a bit of time to explore that programme and you were able to figure out the selection, the conditions on the actions that were carried out if those conditions were true.

So let's have a look at a couple of those examples that were inside our programme.

So there's this first one here, which is if left arrow key is pressed, point in direction of minus 90, move 10 steps.

So that is an example of selection using that if statement.

So the condition that's included is either true or false.

If is our key point in there for selection.

The condition, which must be true or false, is the left arrow key is pressed and the actions to be carried out if that's true point in the direction of minus 90 and move 10 steps.

So that was one example that was within that programme that you were just exploring.

Another example is this one here now.

If touching colour red.

So if the sprite was touching the colour red, then say you completed the app, but it may store full two seconds.

So the condition used here, true or false is the sprite is touching the colour red.

And the actions be carried out if that's true was the say you completed the maze for two seconds.

So that is another example of how selection was used within that programme, the condition within that and the action to be carried out if that condition was true.

We're going to dive a little bit deeper into the Scratch programming language now, we're going to look at how we can use conditions in the programmes.

So you can see on the screen, there is a blue hexagonal command block, and that is how we would use conditions within that environment.

Now selection blocks within the environment have a hexagonal hole so it's a place where we can place one of these command blocks.

So let's have a little look at that now.

So you've got your if block there and inside that was a hexagonal hole, which is now being filled with this condition block.

And the condition is if the key space is pressed.

So if the space bar is pressed, the action will be carried out and you can see the action, which is move 25 steps is inside our if statement or if command block, sorry.

So that is the way it looks within that Scratch environment.

On the screen, you've got three different code snippets.

Now we're going to very briefly go into a project and we're going to have a look at these very briefly before your next task.

The first thing I'm going to do then is open up that Scratch project.

So I'm going to choose the short link, which you would've been given on your task sheet as well, just to open up the project we're going to be looking at.

Now if you're in your own account and you're using your own account, you can remix this project so that you have a copy inside your own account.

If you're not using your own account, that's absolutely fine.

We click see inside, which we're going to do anyway.

If you use the file option at the top up here, you can save that to your computer so do that after your tasks or do that after each lesson and you have your own copy on your computer, which will be able to open up into Scratch.

Now inside the project, we've got these three code snippets down the side here, A, B and C.

And we also have this fourth code snippet here.

Now this is not an example of condition.

This has been provided just so you can reset your sprite.

So if you want to run your programme again, if you use the down arrow, it will reset your sprite to its original position.

Just briefly, if we have a look here, it says change colour effect by 25.

What that means is it's giving it a value.

Now in Scratch, the colour values are represented by numbers.

That's something that you would need to know before you get started.

So that's something that will happen in Scratch.

You've got number values for colours.

Now your task, you're going to have a table structure on your worksheet, or you can do this on paper if you've got a piece of paper, but you're going to be identifying what conditions have been used and you're going to write down the actions that will happen when the condition is true.

So as I just mentioned, you're going to be looking at the conditions that are in that programme and you're going to look at the actions that take place if those conditions are true.

There is a table structure on your worksheet so use that to note down your answers and we'll go through them together once you've finished your task.

Pause the video now, complete your task and resume the video when you're finished.

Welcome back, hopefully you've had a bit of time then to explore the programme and the conditions and actions within that programme.

So we're going to jump into the Scratch environment again now and we're just going to check out what the conditions are and what happens when those conditions are true.

So hopefully you are able to work out the conditions that were being used by this programme and what the actions were when those conditions were true.

So let's have a look at A very quickly.

We've got if key space is pressed then change colour effect by 25.

So if I run my programme, I'm going to start my programme up here.

And if I press the space button, you can see my sprite is changing colour each time I press the space button that is changing by that 25.

Remember that 25 is a representation of a colour.

So each time it's moving up that representation by 25, which makes it a new colour.

Step back to the original byte pressing it down, sort of resetting our project.

B if touching the colour red, then move 25 steps, change colour effect by 25 and then we'll do that one in just a second.

And then we've got this C out here.

So if up arrow is pressed, then move 10 steps.

If on edge, bounce.

So up arrow is pressed.

It moves 10 steps at a time, and it bounces.

As you can see, it bounces when it hits that edge.

And then it will move this way.

Now let's have a look at B then.

If touching colour, move 25 steps and change colour effect by 25.

So you can see there it was very quick, but it moved my sprite by 25 steps and it changed the colour of my sprite as well.

We'll try it one more time.

And again, it's changed the colour effect by twenty-five.

So those were the conditions.

You've got space bar pressed, touching the colour red and up arrow pressed, and the inside each of these if statements are the actions that will take place if that condition is true.

So we've just had a look at some of the code snippets within that programme and you've had a look at the conditions and the actions that take place.

So now we're going to have a think about modifying conditions.

I want you to have a look at the two programme code snippets on the screen at the moment.

And I'd like you to pause the video and identify any similarities between the two code snippets and any differences between them.

So pause the video, consider that what are the similarities and what are the differences, off you go.

Welcome back, hopefully you've had a bit of time then to pick out the similarities and the differences between the two code snippets that were on the screen.

So let's run through them together now.

So similarities, they both used a condition.

You can see that from that hexagonal blue command block.

They both used selection, they both have an if then statement.

They are both changing the colour effect by 25.

So each time that condition is true, they would change the colour effect of the sprite by 25.

And they both use repeat.

They both use a repetition of some kind of a forever block.

Hopefully the only difference you've managed to spot is the condition that's used.

So they're different.

They are both using conditions, but they're using different conditions.

So the top one is using key R pressed and the bottom one is using key space pressed.

So that is a difference between those two code snippets.

So we're going to look at modifying conditions within our Scratch environment.

You have another short link on your worksheet and in a moment, we're going to have a look at what you're doing for this next task.

So I've opened up that short link now.

I'm just going to go and see inside the project.

And you can see, I have four code snippets.

Again, there is a fifth one over here, but that is not an example of conditions so it's not part of this programme, part of this task, sorry, it's there for you to reset.

Now what you're going to be doing is changing and modifying the conditions in each of these code snippets.

These are all dropped down.

You can see that they're dropped down here.

So you are able to go and amend and modify these conditions and just run the programme and see that they've changed.

Just make sure that your conditions have changed.

And you can do that by using the arrows or the keys that you've added to your conditions.

Do remember you need to run new programme before that will work.

Task three then is to open up that short link.

You've got to modify the conditions within each of the code snippets in that programme.

And you're going to run the programme to check that your new condition is allowing the actions to take place.

Pause the video, have a go at doing that now and resume the video when you're done.

Welcome back, hopefully you've had a bit of time then to amend and modify those conditions and you've run the programme just to check that your new conditions are resulting in the correct actions.

That was the last task for this lesson, but we do have one more thing to look at before we finish up.

So I'd like you to have a look at the code snippet on the screen, and I'd like you to consider if selection is used.

So pause the video briefly, consider whether selection is used in this code snippet and resume the video when you're finished.

So let's have a look, is selection used? Yes, you can see that because it's got that if then statement, that command block in the middle there, if then.

So selection is used within this code snippet, and it's if something is true, then do this.

What condition is being used there? So pause the video, figure out what condition is being used by this code snippet, and resume the video when you're finished.

Welcome back, so hopefully you've noticed then that the condition being used is colour red is touching colour green.

So colour red is touching green, that's our condition.

So that if statement would all depend on whether the colour red is touching the colour green.

Final thing I want you to consider then, what actions will take place when the condition is true.

So pause the video, have a quick think, and resume the video when you're done.

So hopefully you've noticed then that the actions that will take place go to X minus 208 Y 155 point in the direction of 180 and change the colour effect by five.

So those are the actions that will take place if that condition is true within that selection book.

That concludes lesson one of the selection in quizzes unit.

I hope you've enjoyed having a look through Scratch, having a look at the conditions being used and the actions that will take place.

In the next lesson, we're going to look a little bit more at selecting what outcomes will take place within our conditional statements.

Please consider sharing your work with us here at Oak National Academy, we'd love to see it.

If you'd like to do that, ask your parent or carer to share it on Facebook, Instagram, or Twitter, tag @OakNational and #LearnWithOak.

I look forward to seeing you all for lesson two.