Lesson video

In progress...


Hi, I'm Ben and welcome to lesson 6 of our programming unit.

Now this lesson is all to do with problem solving.

So we're going to bring together all the skills that we've learnt about so far in this unit.

All you'll need for today's lesson is a pen and paper and you'll also need access to the website, Scratch.

And if you'd like to save your work, you need an account, and if you're under 13, you'll need to ask your parent or your carer or a teacher, to set you up with an account in advance.

Okay, so if you can clear away all distractions that you might have, and when you're ready, we'll get started.

Okay, so in this lesson, it's really all about you pulling together all the skills that you've learnt throughout this unit.

So we want you to design and apply your programming constructs to solve a problem.

And within that, I want you to use subroutine, selection, count-controlled iteration, operators, and variables.

So the first exercise I wants us to do, to get us started is a little bit of a game, and it's called, "Beat the teacher", and in this case your teacher is me.

So your job is to beat me, and I don't know if you could have any more motivation than that to complete a task.

Okay, so I would like you to get your pen and paper and I'd like to set yourself, and to do this, please be honest with it, because you can talk to the, you definitely going to beat me, is that I want you to give yourself 60 seconds, and I'd like you to write down all of the keywords that you can think of, that so far, that you've covered throughout the unit.

Okay, so 60 seconds, write it down.

And then when you've done what I'm going to do is I'm going to see if I can real off as many of those keywords as I can and see if you could have written down more than me.

Okay, so start your 60 seconds, so pause the video, start your 60 seconds, write down as many of those words as you can.

Okay, so off you go.

Right, so I'm assuming that you did take 60 seconds and you've got to promise that you didn't cheat, okay? So I'm going to see if I can do it, okay? So I'm not going to set myself a time because I think I'll probably run out of ideas before 60 seconds.

But I'll see what I can do.

So you can count your fingers as you want.

I think everyone out get more than 10.

I don't know we'll see.

We'll see if it, we'll cross that bridge when we get to it.

So starting now, so I think we covered sequencing, we covered variables, we covered operators, and we covered logic operators, logic operators, I won't recount operators, so logic operators, comparison operators, we did selection, we did conditions, we did iteration, we did count-controlled iteration and condition-controlled iteration, I never got any more, I've got nine so far.

I probably missed something out really important.

I'm going to stop there.

I've got nine, okay? So let's see how I got on.

Did you get more than nine? So we'll see.

So, sequencing, yeah, I got that.

Subroutines, oh, I didn't mention subroutines.

Okay, so subroutines is one I missed out.

Variables, selection, yes, if/else, ah, I didn't say that, conditions, comparison operators, yes, logic operators, yes, iteration, yes.

Ah, I just thought I could have said true or false as well.

Loop, count-controlled and condition-controlled.

Okay, so those are all the ones that I wrote down there.

Did you get all of those? Did you get more than me? You probably did.

But if you did, really well done.

I'm really impressed.

And I'm not at all competitive and I don't feel bad about it, I do.

Okay, so, hopefully, that has got us warmed up for this lesson.

So the task, and this is going to be the main task for this lesson, which is called, "Moves like Jim." Okay, so Moves like Jim is a dance game that requires the user to make Jim perform a dance move by pressing keys on the keyboard at the right time.

So your end of unit task is to complete a partially-built programme that allows the user to play the game and to make Jim perform some smooth moves, okay? So before you start a task, you've got to spend some time looking at the code and running through it to see what happens, okay? So what you'll need for this is you'll need your worksheet and you need to start at Task 1, and then work your way through all the tasks.

And then you'll also need the starter programme which is linked on your worksheet.

So that'll take you to a Scratch programme, you select C inside, and then just start working through your tasks in your worksheet.

Now because this unit is all about combining all the skills that we've learned throughout this unit, I'm really keen for you to try and solve some of the problems that you may come across all by yourself.

Now don't be worried if you come across any problems or something doesn't work the first time, that is absolutely perfectly normal, and you wouldn't be a normal computer programmer if that didn't happen, okay? Now, what's really important though, is that you feel confident to be able to overcome the problems by yourself.

So if you remember in the last lesson in lesson five, we did a exercise on debugging.

Well, we looked at putting some, say blocks in there that helps us work out the value of a variable.

I mean, that might be a technique that you use in this lesson.

But there are three things that I'd like you to kind of use as your principles, as a computer programmer, when sort of trying to solve some problems. So number one, is carefully read over your instructions again, and just stop and take a pause and think through the problem, okay? There's nothing wrong with not wanting to rush through it and just stepping back from it and just taking time to think about it, okay? So read the instruction again and it might help you spot something that you've missed out.

And also read any support tips that we've got in the worksheet and look at your work from the previous lessons and tasks.

Because, remember, this is an end of unit task.

There's nothing in here that's going to test you on something that you haven't already covered in this unit.

So do look back at some other, some other of your Scratch programmes that you've made, and that might help remind you about how to do some selection or how to use variables or how to do some iteration, okay? And then, finally, and if this is available to you, it's really a good idea to talk through your problem with someone else, and they don't need to be an expert, they can just be somebody who you describe the problem to.

And it's quite a common thing that programmers do, it's called rubber ducking, it's like talking to a rubber duck.

If you talk to somebody else and you try and explain the logic that you're trying to apply, often it actually you get that light bulb moment and you think, "Oh, yeah, of course." just when you're trying to explain your code to somebody.

Okay, so give all those things a go.

Now, again, go back to your worksheet now please and find your Move like Jim tasks.

Now I'd like to work through Tasks 1 to 4 'cause they will complete the main part of the activities.

But remember that there are Tasks 5 and 6, but they're optional activities so if you found it all went smoothly and you want to do a little bit more then you can also do Tasks 5 and 6, okay? Most importantly, please enjoy this, it's meant to be fun, you're meant to enjoy it, okay? So don't feel worried about it.

Take your time, and good luck.

Okay, so how did you get on with that? Now, hopefully, you've completed at least Task 1 to 4, but if not, then what we'll do is we'll have a look through the solution.

I'm not going to show you exactly how to build it, but I'll show you my attempted solution at it.

And then maybe you could have a look what I've done and see if you can replicate that in your own programme.

I'm also going to show you how to complete Tasks 5 and 6, which were the Explorer Tasks, so you didn't have to complete them.

But, again, it might give you a bit of inspiration, if you didn't complete them, of something that you might want to do, either in this programme, or any future programmes that you want to build.

So the first task was to look at tasks, sorry, define move on our subroutine, move one.

Now, it was mostly completed for what you have to do was to maybe add some kind of movement to if they did it, right.

So it had if key C was pressed, then what do you want to do? Now one of the Explore tasks was to add a score.

So ignore that bit for now.

But the bit that I did do was to switch to costume to Jim G.

Now you didn't have to go for that particular costume it just whichever costume that you like the most.

And remember if you go to the costumes tab at the top left-hand side, then it should show you all the different moves that Jim is able to do.

So it's up to you to pick the one that you like the look of the most.

And I quite liked that one.

So Jim should make that movement when we run subroutine one, so move one, and also that they press and hold down C, okay, so I can test that out.

So I'm going to run my programme, says, "welcome" got countdown.

And then I'm going to press and hold down C so I'll do that.

And then hopefully, oh, now my keyboard went to sleep annoyingly when I did that, so I'm just going to run that through again.

Three, two, one and that's going to say press and hold dance, press and hold C and they should move to costume G.

There we go.

I need it right, perfect.

Okay, so the next task I gave you was a subroutine for dance move two.

You were provided with all the blocks, but the blocks are all jumbled up.

So what you have to do is put them together in the right order.

Okay? So what you needed is the instruction, first of all, so say press and hold Q and W.

And then we have our selection statement.

Now remember our operators that we're using.

So this is a logic operator.

So we have to use the and, so if the Q was pressed, and the W key was pressed, then it'll move to that costume, costume A, and if it didn't it'll move to costume, C, now at the end of it, we're moving back to our normal costume so Jim doesn't get stuck on his costume A or costume C, he's going to move back to costume B, okay? Now again, move three allowed you to have a little bit of creativity in terms of what you wanted to happen.

But the key part of it, the instructions said you needed to use the OR operator, okay, which again is a logic operator.

So if you press hold one or nine, two seconds, so I had to get my OR operator, and then say if key one was pressed or key nine was pressed, and then you could decide on your own little dance move, okay? So, if I just double click this one, it should just do this one, press one or nine.

Oh, I didn't do it in time.

Let me just try again.

It's going to do it.

It's not doing it now.

Okay, so maybe start my programme from the beginning.

So what I'm going to do to save you from having to watch all these subroutines happen so far, I'm going to just kind of move around.

So remember, this is calling my subroutines in the order that I want.

So I'm just going to put them out of the order and I'm going to get it so it just does move three.

Okay? So when I click the green flag, it's not going to run the other subroutines.

It's just going to do that move three.

So let's have a look.

Press or hold one or nine, there we go.

And do you see the way I've got I made him do a little dance there.

Okay, so I'm just going to quickly show you how I did that.

So we needed to count down there and just resetting back to how it was.

Okay? Right, so I put it in a loop so I used my count-controlled iteration, so it repeats that move five times, he swaps to costume D, waits for a third of a second, swaps, but to the other costume, waits another third of a second.

And it does that five times.

So it makes him look like he's actually doing a dance like this.

Okay, nice.

The last, one other thing that I think has to do with the main tasks was to change the code to make it more, remember not efficient, but elegant.

So when we had countdown, you had the blocks of five, four, three, two, ones, you had all those blocks in there which had the same block repeated lots of times, and remember, as we said, when you have the same block, repeated lots of times, or any block that you see that's repeated lots of times, often we can look at maybe making it more elegant.

And by using iteration or, in other ways, but in this case iteration.

So I had to set my countdown timer to, so, the variable start to five, repeat five times, and then say the number.

So you'll say whatever value has been held by start for one second, and then decrease the value stored by the variable one for each time the loop.

So the first time start is equal to five, so it's going to say start for one second, then it's going to change it to four because we're five minus one is four, that's going to repeat again, so it's going to say four, because four spins stall by start, for one second, and then starts can reduce again.

So three, just going to say three, two, can say two and one.

It's going to say one, okay, and that's going to start.

So that's how we did those bits.

Now, the other things that I asked you to do was to create a score.

So these were the Explorer tasks.

So to create a score, it was just like we did in the previous lesson.

I've started off the programme by setting the score to zero.

So it starts off whenever you start a new game, the score is going to start at zero and I can prove that so when I click the green flag, you should see start move to zero and it does.

And then every time the user gets the right keys at the right time, we change the score by one, so you can see my change score by one block there.

Okay? And I put that in each one of my subroutines to make sure that every time they got one right, increase that score, and then the very final thing, so this was task five, we have to add some feedback for them.

Okay, so where did I put my feedback? So I created another subroutine called feedback.

So if you see the way I called my subroutine, so it calls the countdown one, and then we do move one, two, three and then the feedback subroutine in the end there.

So my feedback subroutine I put some very simple selection in here.

So all I did was when it calls that subroutine the subroutine's going to say if score is greater than two.

So if that expression evaluates to true, is going to say well done for two seconds.

Otherwise it's going to say Better luck next time.

Okay, so let's run through my programme from the start to the end.

Okay, and see what score I can get.

So welcome to Dance Battle, five, four, three, two, one Okay, I'm ready.

Now dance.

So I need to press and hold C.

I'm doing that.

There we go.

I've got it right.

Q and W.

Didn't get in time.

One or nine, no, not that.


And then it's going to get my feedback and it says Better luck next time because I got two out of three.

I needed to get three out of three to be able to get my well done feedback.


So that's how I've solved all the problems, remember then the task allowed you to have a little bit creativity.

So your solution doesn't need to be identical to mine in a lot of ways.

But if you did struggle with any of it, or you want to kind of go back to your programme, then please do you can always rewind this video to the point where I talked about the bit that you got stuck on.

But anyway, so once you've done that, you can continue with the video and we'll move back to the slides.

Okay, so we've got some really good news for you.

Now a game development company has seen your Moves like Jim game and want to hire you to create a new game called Dance Battle.

So the company wants to give you help developing your skills and giving you more training.

So what I'd like to do is go over to your task sheet again, and go over to task seven, and on your worksheets there, complete the activities because this company wants to learn a little bit more about you, maybe where you feel your skill set is and what you'd like help developing next.

Okay, so go to the worksheet and when you're ready with that, when you finished, unpause the video, and we'll finish off the lesson.

Well, that's it for this lesson.

And sadly that's it for this unit too.

And I really hope you've enjoyed it as much as I have.

Now, you've got to give yourself a big pat on the back how much you've achieved in this unit.

Don't underestimate it.

We've covered some really key core foundation programming skills, and they are sequencing, selection and iteration.

Now these are skills that now you know them and have an understanding of them, you should now feel that you're at a level where you can now push your programming skills on further.

So if you enjoyed what you've done then please do let us know about it.

And we again would love to see your work and anything that you've done from this unit.

Or even if you've learned some skill from this unit and thought I would now like to make this programme on my own.

Please share it with us 'cause, like I said, we would really like to see it.

Okay? Now don't forget, there's an End of lesson quiz for you to take which will test you on some of the things that we've learnt in the unit as well.

And then all's got left for me to say, if you do want to share your work, then please ask your parent or carer to share it on Instagram, Facebook or Twitter, typing @OakNational and #LearnWithOak.

Okay, that's all from me.

So I hope you enjoyed it and I hope you also take some other units on Oak Academy.

Okay, so I'll see you then, bye.