Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE

## What do I need to Learn?

 I need to learn how to use the python turtle module to draw a basic shape I need to learn how to use basic functions in turtle module to create and fill simple geometrical shapes

## Python Turtle

• Python is a highly popular programming language, used by many large organisations including Facebook, IBM, Google and Yahoo among others. It is considered by many to be one of the easiest languages to pick up.
• One of the big attractions of Python is that many 'libraries' are available to provide it with extra functionality. A library is a set of extra functions that help perform different types of task. There are libraries for advanced maths, graph drawing, graphics, game writing, random numbers and so forth.
• We're going to use a fun library called 'Turtle', which allows for the convenient drawing of lines and shapes.

Tick each task when you have successfully done it in the following list:

Click inside the Turtle Box below
In the space below 'import turtle' type the following:
1. t = turtle.Turtle()
2. t.forward(100)

Now click the Run button

It should look like this:

• Let's add a "turtle" to the screen. We can move this around the screen to draw shapes and patterns. We'll call our turtle, "Tim".
• As we always use lower case for variable names well call "Tim" "tim".
• Let's give Tim a turtle shape and a colour.

Tick each task when you have successfully done it in the following list:

Click inside the Turtle Box below
In the space below 'import turtle' type the following:
1. tim = turtle.Turtle()
2. tim.shape('turtle')
3. tim.color('green')
4. tim.forward(100)

Now click the Run button

### Here are some more commands see what you can do with them:

• tim.backward()
• tim.pensize()
• tim.home()
• tim.clear()

• ### Drawing a simple square:

• We have so far drawn a line using the forward() command but if we want to chage direction then we need to use some more commands left() and right().
• The numbers we use inside the brackets for left() and right represent angles, so if we want to go at a right angle we type left(90).
• Using that basic information lets see if we can draw a square.
• Lets try the following tasks:

Tick each task when you have successfully done it in the following list:

Open Thonny
add in the lines code below:
1. import turtle
2. tim = turtle.Turtle()
3. tim.shape('turtle')
4. tim.forward(100)
5. tim.left(90)
6. tim.forward(100)
7. tim.left(90)
8. tim.forward(100)
9. tim.left(90)
10. tim.forward(100)
11. tim.left(90)

Now click the Run button

• Can you see that the above code repeats itself four times?
• Can you rewrite your Python code using a 'loop' so that we don't have to repeat the lines of code?

### Summing it all up

Lets look at the learning outcomes and decide which one best describes our current level of understanding :

Tick the one you feel is closest to your level

## Learning Outcomes I need to learn how to use the python turtle module to draw a basic shape

• I have a basic understanding of how I can use the python turtle module to draw a basic shape with a little help from my teacher
• I can show my teacher that I can use the python turtle module to draw a basic shape without their help.
• I can use the python turtle module to draw a basic shape independently and I can also explain it to others and can complete any extension tasks I am given.

## 🠜 Now update your learning objectivesClick on the Assessment image

### Creating a filled in Triangle

• When you are drawing shapes you can also fill them in as longs as you put your fill command at the beginning and end of your shape.
• Lets try the following tasks:

Tick each task when you have successfully done it in the following list:

Create a new Thonny file
type the following
1. import turtle
2. tim = turtle.Turtle()
3. tim.shape('turtle')
4. tim.begin_fill()
5. tim.forward(100)
6. tim.left(120)
7. tim.forward(100)
8. tim.left(120)
9. tim.forward(100)
10. tim.end_fill()

Now click the Run button

### Can you draw the Microsoft logo?

• Using the fill command and the Turtle Box above can you now draw the Microsoft Windows logo.
• hint: to change the fill colour you will need to use the .fillcolor() command with the name of the colour inside the brackets.

### Summing it all up

Lets look at the learning outcomes and decide which one best describes our current level of understanding :

Tick the one you feel is closest to your level

## Learning Outcomes I need to learn how to use basic functions in turtle module to create and fill simple geometrical shapes

• I have a basic understanding of how I can use basic functions in turtle module to create and fill simple geometrical shapes with a little help from my teacher
• I can show my teacher that I can use basic functions in turtle module to create and fill simple geometrical shapes without their help.
• I can use basic functions in turtle module to create and fill simple geometrical shapes independently and I can also explain it to others and can complete any extension tasks I am given.