Lesson video

In progress...

Loading...

Hi, my name's Mr. Hall, and I'm really looking forward to learning with you today.

This lesson is called Programming a Turtle.

And it's the first lesson from the unit Repetition in Shapes.

The learning outcome for this lesson is that you will type programming commands accurately.

We've got three keywords in this lesson.

So the first keyword is programme.

So a programme is a set of commands that can be run by a computer to complete a task.

Then we've got command.

A command is a single instruction that can be used in a programme to control a computer.

And finally we have turtle.

And turtle is a small shape on the screen that moves and draws when given commands.

So there's our three key words, programme, command and turtle.

We've got two learning cycles in this lesson.

First of all, we're going to look at using text-based commands and then later in the lesson you'll navigate with the turtle.

So let's have a look first at using text-based commands.

So Aisha and Lucas wanted to go to the shop, but they ended up at the ship.

Aisha asked her mum for directions and they followed them exactly.

Aisha checked a message and it said, ship not shop.

This story shows how important it is to be accurate.

One letter made all the difference in this story.

Being accurate means correct and exact without mistakes.

When we programme, it's really important to be accurate.

In this lesson we're going to be using Logo.

Logo is a text-based programming language.

You use Logo to type commands that are then drawn on the screen.

And we'll look at some examples now.

First of all, let's look at the Logo screen.

So there's four parts shown here.

So first of all, we have the turtle in the middle of the screen.

So that's the small triangle that's what's gonna draw the shapes.

The big rectangle at the top is the drawing area.

Then we have at the bottom the command box.

So that's the smaller rectangle at the bottom.

And then on the bottom right there's the execute button.

And the execute button runs your commands.

Don't worry if you're not sure about what some of these things mean, you're gonna see them working in the next few slides.

So you'll understand once you've seen the examples.

When you programme the screen turtle correctly, it will draw a line as if it has a pen underneath it.

So here you can see the turtle has moved slightly up the screen and there's a line behind it.

And underneath we've got a command which is forward 100, fd 100.

So you type your command into the command box, down here at the bottom where it's highlighted.

There's the command box.

And then to run it you press the execute button.

And where's the execute button.

So this is the command to move the turtle forward 100 steps.

So we've already seen this.

So forward 100 steps is fd 100.

And there you see it fd 100.

When you type it in, make sure you type a space between fd and 100.

So remember the story about being accurate.

This is where one of those times we need to be accurate so we need the space between the fd and the 100.

So that's where the space goes.

So the larger the number value, the longer the line that will be drawn.

So this time we've got the command fd and a space and 50.

This command will make a shorter line than the previous one as the value 50 is smaller than a 100.

And on the Logo screenshot there you can see there's a shorter line than we saw in the previous slide.

So let's have a look at the question.

What does fd 100 do in Logo? Does it A, move the turtle forward 100 steps.

B, move the turtle backward, 100 steps.

Or C rotate the turtle 100 steps.

Well don, the right answer is A, it moves the turtle forward 100 steps.

So let's have a look at some more commands now.

So now we've got the command cs, which is clear screen.

So the C stands for clear and the S stands for screen.

It will clear any lines drawn on the screen and it will also move the turtle back to its starting position in the middle of the screen.

So the command to move the turtle backwards is bk.

So have a look at the examples there, which output is from the command bk 50? And which output is from the command bk 100 and why? Well the first drawing shows the output from bk 100 and you can see that we've got a slightly longer line than we've got from in the second drawing, which is from the command bk 50.

So the second line is shorter, so it uses a smaller value.

So on the left we use bk 100, and on the right we use bk 50.

Watch this animation demonstrating the commands.

So first of all, it's forward 50.

So the turtle moves forward 50.

Then we're going to clear the screen, so the line disappears, turtle back to the middle.

Backward 100, so a line backwards, clear screen again.

Backwards 50.

So it's shorter line drawn backwards and clear screen again.

So there you've seen all of those commands, forward, clear screen and backwards being used.

So your task is to open Logo and practise using the forward, fd, and backward, bk commands.

Try three different values for each command to see how far the turtle moves.

Remember to use cs, clear screen to reset before trying again.

How many steps does it take to get the turtle right to the top of the screen? And finally, what happens if the turtle goes off the screen? So the answer number two, how many steps does it take to get the turtle to the top of the screen? Forward 350 moves the turtle right to the very top of the screen.

And what happens if the turtle goes off the top of the screen? So if the turtle moves past the top of the screen it will disappear and then reappear at the bottom.

Let's move on to the second learning cycle, which is navigate with the turtle.

The turtle can also turn left and right.

So here's two new commands, lt for left turn and rt for right turn.

With these commands, the turtle rotates on the spot.

The value after lt or rt is a degree of rotation.

The number value tells the turtle how much to turn.

A smaller number makes a smaller turn and a bigger number makes a bigger turn.

Let's have a look at an example.

So right turn 90, will turn the turtle to the right 90 degrees.

Right turn 180, will turn the turtle 180 degrees.

And right turn 270, will turn the turtle 270 degrees.

So here you can see that 90 degrees represents a quarter of a turn.

By combining forward, fd, with right turn, rt, and left turn, lt, we can use the turtle to draw different combinations of lines.

So this code is forward 100, right turn 90, forward 100, right turn 180 and forward 200.

And this code would draw this T shape.

So to start with the code would take it forward 100, it would then turn right 90 and move off to the right.

Then it would do another right turn 180 degrees.

So then point in the other direction and move forward 200 to move all the way across to where the turtle is now where you can see it on the screen.

So there's a combination of five commands which would draw that T shape.

Here's another example of how we can combine forward with right turn and left turn.

We can use the turtle to draw different combinations of lines.

So this time we start with the right turn.

So the first line goes off at a 45 degree angle, so no longer straight up, but 45 degrees to the right.

Then it moves forward 50, then it does a 45 degree left turn and then forward 100.

Watch this animation demonstrating the commands.

So we've already got right turn 45, forward 50, left turn 45, forward 100.

And there you can see how the shape on the previous slide is drawn in Logo.

Let's have a look at the question.

What will the command rt 90 do? Is it A, the turtle will move 90 steps backwards.

B, the turtle will rotate 90 degrees to the left.

Or C, the turtle will rotate 90 degrees to the right.

Well done.

The answer is C.

The turtle will rotate 90 degrees to the right.

So the command rt 90 stands for right turn 90.

Instead of writing command step by step.

You can also combine commands together on one line.

So in this example we've got forward 100, right turn 90 and forward 100 all on one line.

And that produces a shape with two lines with a right angle in the middle.

Remember to separate each command with a space.

So in this code the forward and the 100 are separated by the space, the 100 and the right turn, rt, separated by space and so on.

Each command is separated by a space.

So have a look at this animation demonstrating combining commands.

So we have forward 100 space, right turn 90, space, forward 100.

And then we have the same shape that you saw on the previous slide.

So it's a really good way of combining commands by putting them all on one line.

The final commands we'll look at in this lesson are pu and pd.

So pu stands for pen up and pd for pen down.

The command pu, for pen up makes the turtle move without drawing a line.

Like lifting your pen off the paper to move it to a new spot.

Use pen up when you want to move to a new position without drawing a line.

The command pen down makes the turtle draw a line as it moves like keeping your pen on the paper whilst drawing.

Use pen down when you want to draw a line.

Watch this animation demonstrating the commands.

So we have forward 100, left turn 90, forward 50.

Then we're gonna take the pen up, move the turtle forward 100, put the pen down, and go forward 100 once again.

Left turn 90 and forward again.

So here we have two shapes separated by the gap in the middle when we lifted the pen up using the pen up command.

So fill in the names of these commands.

Fd is the command for forward.

Bk is the command for backwards.

Rt is the command for right turn.

Lt is the command for left turn.

Cs is the command for clear screen.

Pd is the command for pen down.

Pu is the command for pen up.

So in Logo first use the commands to draw an L shape.

So you can choose from the commands you can see on the slide.

So you've got all the commands we've looked at in this lesson.

So forward, fd, backwards, bk.

Right turn, rt, left turn lt, clear screen, cs.

Pen down, PD, and pen up, pu.

Once you've done that, compare your code to a partner's programme and see if there are any differences.

So let's have a look if we found any differences.

So Aisha programmed her turtle to turn left first and then forward and a right turn and then one more forward.

So that's the code Aisha used.

Left turn 90, forward 100, right turn 90, forward 100.

So use forward, pen up and pen down to draw a dotted line.

Try using smaller values to make more of your path fit on the screen.

Here's how you could draw a dotted line.

You could start with fd 25, and then pu, fd 25 and then pd, fd 25 and then pu, fd 25, pd.

And finally fd 25, pu.

So let's have a look at the summary of this lesson.

So a programme is a set of commands that you can use to control a screen turtles movement and drawing.

There are commands to move the turtle forwards or backwards, turn it left or right.

Move it with or without drawing a line.

And to clear the screen to start fresh.

It's important to be accurate with commands so that your programme works correctly.

Well done for taking part in today's lesson.

I've really enjoyed learning with you today, and I look forward to joining you for the next lesson.