video

Lesson video

In progress...

Loading...

Hi, I'm Rebecca, your computing teacher.

And how awesome is it, you've made it to lesson six, well done.

For this lesson, you're going to need that wrap up account, that you set up with your parents or carers permission.

And you're going to need the programme, that you started in lesson five, that task one and two, the planetary quiz, that you've been working on.

And you're going to need a pen or paper, to make notes if you want to.

And you're also going to need to make sure that you move, as many distractions as you possibly can out the way, so you can really focus on this last lesson of the unit.

Are you ready for it? When you're ready, we can begin.

So in this lesson, you will be continuing with your mini project, that you started in lesson five.

So what I'd like you to do is, pause the video and go to the worksheet, 'cause the worksheet is going to take you through task three and four of the planetary quiz.

And, if you struggle with it, or you need a little bit of support, don't worry because after this screen, I will be going through how I've decided to code it, and you'll be able to see me live coding it.

So if you want to code along with me, then that's absolutely fine.

You could just go ahead and code along with me, or you can just pause the video and read the tasks yourself, and try and have a go at it first, depending on what you need, you choose the option that you want to choose.

So pause the video now, while you have a go at doing it yourself, or just keep watching and you can code along with me.

Off we go.

This is where my code had got to at the end of lesson five.

So you can see, all the way to the top.

We've got that input statement, for that random integer function.

And then we've got the list of planets, and then it's picking one at random.

We've got question one and the output.

We've got another picking at random in question two.

And now the task three is to work on question three.

So I've got the checklist in front of me for what I have to do for task three.

So I've got there, randomly selects a planet for the third question, making sure it's not the last planet in the solar system.

So I've got to select one at random, so I can use all of that code again.

But there's going to be a slight difference, because this one, is going to select the last planet in the list if I use this one.

And we don't want to do the last planet, because the question is, what is the next planet? So if it says, earth, the question is, what is the next question, the next planet after earth, and the answers going to be Mars.

Whereas if I had Neptune, there is no other planet apart from that Pluto, that's got downgraded to a dwarf planet.

But there is no other planet after Neptune, so it wouldn't work.

So I need to make that Neptune doesn't get selected from that random selection.

So, if I just change that to a six, then Neptune's never going to be selected from that list at randint.

So randomly selects a planet for the third question, making sure it's not the last planet in the solar system.

So I think I've done that.

I think that's okay.

So I can test it if I want to, but I'm pretty sure now, I've used that code twice and I've tested it.

So I'm pretty sure it's going to work this time.

So I'm not going to test it at this point.

So the next thing on my checklist was, it displays the name of the randomly selected planet, and asks for the name of the planet that comes after it.

And there's some examples to have a Look at.

So, I've got to do question three, and then I just go up here and I've put question two like that.

So I'm going to have the same.

So print, question, three.

And then I've got to put my actual question.

So, how am I going to word it? Let's have a look.

So print, the, name of the planet, that comes, after, position, from the sun.

Okay.

So I've done that.

So question three.

The name of the planet that comes after position from the sun.

So I'm going to run it and just see what happens and put in some random numbers.

So question three, the name of the planet that comes after three, from the sun.

That's not quite working, is it? That's not what I want it to do.

Displays the name of the randomly selected planet, and asks for the name of the planet that comes after.

So that's not correct.

So what I want instead is not position is its planets.

This is why it's really good to test your programme.

So I'm going to try it again.

Just going to put in some random data, come on.

It's not running so we just try it again.

There we go.

Put some random data.

So the name of the planet that comes after Saturn from the sun.

So its working now.

So it was a good job that I checked that, or else I would have got later down the line and been really stuck.

So, I've got that far.

And then it says, displays a message that informs a user, whether or not the answer was correct.

Now, how am I going to know, what the correct answer is on this one? 'Cause this is a little bit tricky, 'cause we want the next planet along.

It's selecting the current planet.

So I'm going to need a variable ain't I, I think.

I'm going to needed a variable for the next planet.

So I'm going to put next, and then I've got to think, how am I going to get it to know, what the next planet is? So, I wonder if planets, and then index plus one works.

And I'm going to just print it, just to see if that works.

I'm going to give it a go.

So run, two, come on it's been slow today.

Two.

So, the name of the planet that comes after earth from the sun, and it's printed Mars, and Mars is the next planet.

So that's working.

So I've got my variable and it's picking up the next planet.

So that's brilliant.

So now I've got to have the answer.

So answer, equals input, and it's not an integer this time, so we just leave it as input.

And then I can do my condition.

I'm going to put all these bits together.

Then I can do my condition.

So if, next, is equal to answer, or could have an answer equal to next, it's the same thing, print, that is correct, else, that is not correct.

So I'm going to run it again now and see what happens.

So I'm going to put two, two.

so it says, the name of the planet that comes after Mercury from the sun is Venus.

So I'm going to type in Venus.

That is correct.

And then I'm going to do it for the other branch, just to double check.

So, the name of the planet that comes after Mercury from the sun and is Venus again.

So I'm going to get wrong this time and I'm going to put Mars.

That is not correct.

So it's working.

So, I'm getting there, I'm getting there.

So, suppose the messages that informs you as to whether or not the answer is correct, done that, right.

And the final one was, displays the correct answer, even when the user's answer was not correct.

So I need a similar one to what I've got there in line 38.

But it's going to be slightly different worded this time Isn't it.

So I'm going to have, the name of the, planet, that comes, after, what's it going to be, planet, is, and then it's, next.

Not in speech marks, next.

All right.

Let's see if that works.

So two, two, so the name of the planet that comes after Mars from the sun is, my very early morning job Jupiter.

That is correct.

The name of the planet that comes after Mars is Jupiter.

Woo hoo! So, that was my task three working and tested.

So I know it's right.

So if you want to pause now, and try and do that yourself, you can do, or if you're just checking, and just keep watching and see what we're going to do for task four.

Task four then, is to display the score.

So the number of correct answers that the user has.

So for that, we're going to have to use a new variable, that's going to keep track of the score, throughout the gameplay.

So at the very beginning, you're going to need a variable called score.

So, I think I'm going to put it there.

And at the very beginning of the game, the score is going to be zero isn't it.

Because they won't have earned any points.

So then I've got to think, well, wherever they get a correct answer, I need to increment score by one.

So I'm going to go to wherever they're correct.

So if you have a look here, I've got this line of code that says that is correct.

And then I've got another one that is correct.

And another one that is correct.

So within that line of code or after it, or just before it, I can increase the score by one.

So, I gave to my first one and that sounds two.

so go to my first one.

Score, equals, score, plus one.

So every time they're correct, I want to do that same piece of code.

So I'm going to copy and paste it.

Control C and then control V.

So where's the next one.

And then I've got another one.

Where is it? There it is.

And then I can just test that very quickly, by just doing print score and see what happens.

So I'm going to do, what is the position of Mars relative to the Sun? Four.

What is the name of planet number eight from the sun? That's Neptune.

And then, the name of the planet that comes after Mars is Jupiter.

So it should have got three.

So it should say three.

That is correct.

There we find the number, three.

Yes.

So right at the end I've got my three, so I know it's working.

And then I just need to turn that print, and just something a little bit more interesting.

So, you got, out of three.

Like that.

So just try it again.

I'm just going to get it wrong this time.

So what is the name of the planet? Mars.

Name of the planet that comes after Earth is, Mars.

You got one out of three, so it's displaying it correctly.

So updating you all, let's look at my checklist.

Displays the number of questions the user has answered correctly.

So I've done all of those tasks now on the sheet.

There's also explorer task for you to have it go out as well.

And you also might think, well, actually there's quite a lot of repetition as well, going on there.

So, is there something you could do to make this repeat? So maybe you could have something like, keeps repeating the questions possibly, because he could otherwise randomising.

It could go through different questions, and do random questions each time.

So there's some quite interesting things you could do with this programme, now that it's a working quiz, just to improve it and make more questions, for example.

So take a look at the explore task, and it's going to give you some ideas for improving it, and giving some hints, a little bit like, where we did the city guessing game, in a previous lesson.

So you can have a go at that, or just play around with it, and think about what else you could do with the code to make it better.

So it's completely up to you now it's yours.

If you want to just copy my code along, then you can do that now, or if you were just looking at this to check that you'd got it right as well, then hopefully you have got it right.

And if not, you can go in and just make some changes now to your programme.

But Well done wherever you are, you've done extremely well.

That's it.

It's the end of the unit.

You finished lesson six.

So think about all of the progress that you've made, right from the very beginning of this unit, and how much you've learned about all sorts of things, lists and for loops and string, and accessing using operations on string and operations on lists and all sorts of things.

You've even made a planetary quiz game as well.

There's just so much that's gone on in this unit.

So I hope you found it really useful, and that you've learned a lot as well.

I'm really proud that you've managed to stick to it, and get to that lesson six as well.

You've done extremely well.

Its such a brilliant thing to be able to do this, and persevere as well.

So well done, you should be very proud of yourself.

Now, if you'd like to, please ask your parent or carer, to share your work on Instagram, Facebook, or Twitter, tagging @OakNational and #LearnwithOak.

'Cause we'd love to see what you've done with those planetary quizzes, to see if you've extended them, or just to say that you've done it and that you're proud of what you've done.

I'd really love to see what you've been doing.

So well done, and hopefully I'll see you again for another unit.