Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE

## What am I Learning today?

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

## Lesson

1. Set your Learning Objectives to red.

2. ic into this PowerPoint.

3. #### To download the PowerPoint by clicking on the image below

4. Save your PowerPoint as 'Programming 1'

## 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.

Lets try the following tasks:

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

## Complete the following tasks

Open your python program
Copy the following lines of code:
1. import turtle
2. t = turtle.Turtle()
3. t.forward(100)

Now click the Run button

It should look like this:

### Adding shape and colour

• 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.

Lets try the following tasks:

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

## Complete the following tasks

Copy and run the following lines of code:
1. import turtle
2. tim = turtle.Turtle()
3. tim.shape('turtle')
4. tim.color('green')
5. 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:

## Complete the following tasks

Copy the following lines of code:
1. tim.forward(100)
2. tim.left(90)
3. tim.forward(100)
4. tim.left(90)
5. tim.forward(100)
6. tim.left(90)
7. tim.forward(100)
8. tim.left(90)

Now click the Run button

It should look like this

• 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 Shape

• 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 like this.
• tim.begin_fill()
tim.forward(100)
tim.left(120)
tim.forward(100)
tim.left(120)
tim.forward(100)
tim.end_fill()

## Extension task 1

### Can you draw the Microsoft logo?

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

## Extension task 2

### Can you draw this triangle of triangles?

• Use a mixture of trangles and filled triangles to complete the pattern below.

• ### 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.