Loading...
Hello, my name is Mrs. Holbrow, and I'm so pleased you've decided to join me for the lesson today.
We are going to develop our knowledge of sequence using the block-based language, Scratch.
We're even gonna create some music in this lesson.
Are you ready to make a start? Welcome to today's lesson from the unit, "Using fundamental programming constructs in a block-based language." This lesson is called sequence.
And by the end of today's lesson, you'll be able to use subroutines to execute sequences of commands.
You'll need to have Scratch open for this lesson, and it would be useful if you had your worksheet ready.
We will be exploring these key words during today's lesson.
Execute.
Execute, to run or carry out commands in a programme.
Sequence.
Sequence, the order of commands in a programme.
Subroutine.
Subroutine, a named sequence of commands used to perform a specific task in a programme.
In today's lesson, we will compare how computers and humans execute commands.
We will create sequences of commands for a specific purpose, and we will use subroutines to execute different sequences.
Let's make a start by comparing how computers and humans execute commands.
Humans programme computers to perform tasks.
These tasks are often quite repetitive, or tasks that would take a human a lot of time to do.
For example, calculating, making, and finding.
Computers can do these tasks much faster than humans.
Computers are tools which help humans to turn their ideas into real working creations.
One way to do this is to write a computer programme.
When you programme a computer, you give it a set of commands to execute.
It will execute these commands precisely.
Let's watch this video to see how a computer may execute commands.
That may be a bit of a silly clip, but it illustrates the point, that computers need precise instructions.
A computer needs a sequence of precise commands.
The difference between a computer and a human, is that a computer will do exactly what it is told.
It cannot misinterpret a command like a human can.
It also can't try to guess what commands mean, and figure it out like a human can.
If a computer does something unexpected, then it's because the human that programmed that computer wasn't precise enough with their commands.
Okay, let's do a quick check.
True or false? A computer can guess what commands mean.
Pause the video here and have a think.
That's right.
It's false.
A computer needs precise commands.
It can't try to guess what the commands mean and figure it out like a human can.
Andeep is saying that programming is how you use computers to solve problems. There are two key points here.
Firstly, you.
Without the programmer or you, the computer is useless.
It needs you to tell it what to do.
Solve problems. Computers are complex tools that exist to automate tasks and to solve problems. Time for you to check your understanding.
Fill in the blank to correctly complete the sentence.
When you create a programme for a computer, you give it a set of to execute.
Have a think and pause your video whilst you complete the task.
Did you manage to complete the sentence? Well done.
When you create a programme for a computer, you give it a set of commands to execute.
Okay, it's now time for your first task of today's lesson.
In this activity, you are going to be a robot, or at least pretend to be a robot.
You need to successfully guide the robot or yourself to the door.
Start by writing a sequence of commands to get the robot to move from its current position to the door.
So, for example, from where you're sat, to the door.
Pause your video here whilst you write your sequence of commands.
You're now going to test your commands.
You need to follow your commands precisely, because remember, you're acting like a robot or a computer, so you can't make any adjustments.
Pause the video here whilst you test out your commands.
Did you get to the door? If not, go back and improve your commands.
If you did, think about how precise your set of commands were.
Pause the video here whilst you complete the task.
You're now going to instruct your robot to take a different path to get to the door, or a different route.
But this time, the robot can only understand the following commands.
Move forward a certain number of steps.
For example, move forward two steps.
Turn right 90 degrees or turn left 90 degrees.
Pause the video here whilst you complete the activity.
Okay.
Now, for the final activity of this task, Part 5.
If you gave a human some commands to get to the door, would you need such a precise set of commands? Think carefully about your response, and pause the video whilst you complete the task.
Let's have a look at an example answer for Part 4.
You were asked to write a list of commands to get your robot to move from its current position to the door.
Here's an example.
Move forward 10 steps, Turn left 90 degrees.
Move forward 15 steps.
Turn right 90 degrees.
Move forward five steps.
These set of commands are in a sequence.
They come one after another.
You were asked, "If you gave a human some commands to get to the door, would you need a precise set of commands?" Here's a sample answer.
"A human would not need such a precise set of instructions.
This is because they could alter the path if they were not going to reach the door, or if there was an obstacle in their way.
They would work that out and just take a different route." Okay, we're now going to move on to the second part of today's lesson, which is creating sequences of commands for a specific purpose.
Remember, a sequence is a pattern or process where one thing follows another.
We saw in the previous activity in this lesson that we built a sequence of commands for our robot.
When you developed your set of commands for the robot, you were building sequences of commands.
Can you think of any everyday examples where commands need to be carried out in the correct sequence? Pause your video here if you need to have a think.
Here are some examples.
Recipes.
When you do some baking or cooking, you follow a recipe.
And if you didn't follow the instructions in the correct order, you could end up not making the final product correctly.
Another example is music.
Notes are played in a specific order to create a tune or to replicate a song.
Time for a check.
Can you place these commands in the correct sequence for washing your hands? Pause the video here whilst you complete the task.
How did you get on? Well done.
You're doing so well.
So, I've given two sample answers here because there's a couple of instructions that could be done in a slightly different order.
So on the left-hand side we've got, wet your hands with water, dispense soap onto your hands, lather your hands in the soap, scrub your hands, and then rinse the soap from your hands.
In the set of instructions on the right-hand side, we've just swapped the "wet your hands" and the "dispensing soap," 'cause it doesn't really matter which order those happen in.
Sometimes there is more than one possible sequence of commands that will still work or solve a problem.
Can a computer play music? What information would a computer need to play this musical sequence? The computer would need to know what sound each note makes, and how long to play each note for.
Listen carefully to this piece of music.
(gentle piano music) Do you recognise the tune? Is there a sequence or pattern to the music? The music you just listened to is called "Frere Jacques." The sequence of the words in the song is Frere Jacques Frere Jacques Dormez-vous Dormez-vous Sonnez les matines Sonnez les matines Ding, dang, dong Ding, dang, dong Shall we listen to the music again? (gentle piano music) Andeep has noticed that each line in the song is repeated twice.
Let's do a quick check.
The following code blocks have been added to play the "Frere Jacques" song.
Which code block is missing from the sequence? Pause your video here whilst you have a look at the code and have a think.
Did you select A? Well done.
Sonnez les matines is the correct answer, because it's the only line of the song that isn't repeated twice in the sequence.
To create a subroutine in Scratch, you need to use My Blocks.
My Blocks are red code blocks.
Let's watch this animated GIF to see how you can create your own blocks and subroutines in Scratch.
You can see when you click on the subroutine, you can rename it anything you want it to be.
Okay, time for the next task of today's lesson.
Open the Scratch programme that has been started for you, oak.
link/frere-sub.
Create a subroutine for each line of the song.
The first one has been done for you.
Then put the subroutine call blocks into the correct order under the "when green flag clicked" block.
If you're getting a bit stuck, try listening to the melody of the song again.
Pause the video here whilst you complete the task.
How did you get on? You're doing so well in today's lesson.
Well done.
Hopefully, you should have a sequence of code blocks like is shown on the screen at the moment.
So under the "when green flag clicked," we've got frere jacques, twice, dormez-vous, twice, sonnez les matines, twice, and ding, dang, dong, twice.
Sofia's right.
This music will not play yet because the subroutines each need a set of commands.
And we're gonna move on to that now.
Okay.
We're moving on to the final part of today's lesson, and we are going to use subroutines to execute different sequences.
A subroutine is a named section of code.
A subroutine can be called using its name and can be used in different places in a programme.
In Scratch, subroutines are created using My Blocks, like we've just seen.
Sam is asking, "Why do we use subroutines in programmes?" Well, using subroutines makes code more understandable, as the code is broken down into smaller sections.
We call this decomposition.
Subroutines also allow programmers to repeat code without having lots of duplicate blocks.
This makes a programme more efficient.
How did using a subroutine help us when we were programming the Frere Jacques programme? A subroutine could be created for each line of the song that is repeated.
For example, we can have a subroutine for the Frere Jacques line that we can call multiple times in the programme.
Okay, let's do a quick check of your understanding.
A named section of code that can be called in a programme is, A, a sequence, B, command, or C, subroutine.
Pause your video here and have a think.
Did you put subroutine? Excellent work.
A named section of code that can be called in a programme is a subroutine.
Which code block category do you need to select in Scratch to create a subroutine? Is it A, events, B, My Blocks, or C, variables? Pause your video here and have a think.
That's right.
It's B, My Blocks.
Well done.
Okay, it's now time for the final activity of today's lesson, and you've worked so hard.
We're gonna start by opening the Scratch programme provided, oak.
link/frere-song.
Listen to each of the music sequence blocks.
These are the green blocks, and you can listen to them by clicking on the block.
Once you've listened to them, place the sequence under the appropriate subroutine heading.
Pause your video here whilst you complete the task.
Now, add a new sprite and make it sing along in time with the tune.
Use the following song lyrics.
Frere Jacques Frere Jacques Dormez-vous Dormez-vous Sonnez les matines Sonnez les matines Ding, dang, dong Ding, dang, dong Pause your video here whilst you complete the activity.
Okay.
How did you get on? Let's check if you've done the activity correctly.
You were asked to place the sequence under the appropriate subroutine.
On the screen is the solution.
Check your code matches what's on the screen.
Pause the video here if you need some time to check.
You were asked to add a new sprite and make it sing along in time with the tune.
Here's the code blocks you would've needed.
Don't worry too much if you haven't put the waits in, as long as you've got the order of the sequence correct, that's fine.
Well done.
Okay, we've come to the end of today's lesson, and you've worked so hard.
Well done.
Let's summarise what we've learned today.
A computer needs precise commands.
Commands can be put one after another to build a sequence.
Sequences of instructions can be split into subroutines to make code more readable and reusable.
Thanks for joining me for today's lesson, and I hope to see you again soon.
Bye.