Download presentation
1
Using the Python Turtle
GCSE COMPUTER SCIENCE Using the Python Turtle Practical Programming using Python Lesson 16 – Using the Python Turtle
2
You are going to use the Python Turtle
Introduction You are going to use the Python Turtle The Turtle is an arrow you control on the screen It allows you to draw shapes and patterns using Python commands
3
Turtle Commands Main Turtle Commands forward()
Moves the turtle forward a set number of pixels t.forward(50) right() Rotates the turtle clockwise a set number of degrees t.right(90) left() Rotates the turtle anti-clockwise a set number of degrees t.left(90) ACTIVITY Create a new folder in your C2 folder called Turtle. Save all your Turtle work in this folder.
4
Example How to screenshot
Create a program to draw a straight line of length 100 Code screenshot Shape screenshot Do not save the program as turtle.py – see the next slide How to screenshot Use the Windows Snipping Tool: Start / All Programs / Accessories / Snipping Tool
5
Create a program to draw a straight line of length 100
Activity 1 Create a program to draw a straight line of length 100 Code Screenshot Shape Screenshot Save the program as turtle1.
6
Create a program to draw a Square with each line being 100 in length
Activity 2 Create a program to draw a Square with each line being 100 in length Code Screenshot Shape Screenshot Save the program as turtle2.
7
Save the program as turtle3.
Activity 3 Create a program to draw a Rectangle with each long line being 100 in length and the short lines being 50 in length Code Screenshot Shape Screenshot Save the program as turtle3.
8
Changes the colour of the pen
Pen Colour pencolor() Changes the colour of the pen t.pencolor(”red”) Colours include: Red, blue, green, yellow, purple, orange, pink , brown and grey.
9
Save the program as turtle4.
Activity 4 Create a program to draw a red Rectangle with the long lines being 150 and short lines being 100 in length Code Screenshot Shape Screenshot Save the program as turtle4.
10
This is the angle you need to use
Shape Angles Shape Name Number of Sides Sum of Interior Angles Interior Angle Exterior Angle Triangle 3 180 60 360 No. of Sides Square 4 90 Pentagon 5 540 108 Hexagon 6 720 120 Heptagon 7 900 128.6 Octagon 8 1080 135 Nonagon 9 1260 140 Decagon 10 1440 144 This is the angle you need to use
11
Save the program as turtle5.
Activity 5 Create a program to draw a green equilateral Triangle with each line being 80 in length Code Screenshot Shape Screenshot Save the program as turtle5.
12
Save the program as turtle6.
Activity 6 Create a program to draw a red Pentagon with each line being 120 in length Code Screenshot Shape Screenshot Save the program as turtle6.
13
Save the program as turtle7.
Activity 7 Create a program to draw a blue Hexagon with each line being 90 in length Code Screenshot Shape Screenshot Save the program as turtle7.
14
Changes the size of the pen.
Pen Size pensize() Changes the size of the pen. t.pensize(10)
15
Save the program as turtle8.
Activity 8 Create a program to draw a yellow Rhombus with each line being 75 in length Tip: You will need to change the angle before going forward! Code Screenshot Shape Screenshot Save the program as turtle8.
16
Save the program as turtle9.
Activity 9 Create a program to draw a red parallelogram with each long line being 100 and short line being 50 in length and with a pen thickness of 10 Tip: Each small and large angle needs to add up to 180, and each opposite angle is the same Code Screenshot Shape Screenshot Save the program as turtle9.
17
Circles circle() Allows you to draw a circle t.circle(10)
The number represents the radius of the circle.
18
Save the program as turtle10.
Activity 10 Create a program to draw a pink circle with a radius of 50 with a pen thickness of 5 Code Screenshot Shape Screenshot Save the program as turtle10.
19
Loops save you time, below is the code to create a square
For Loops Loops save you time, below is the code to create a square import turtle as t for i in range(4): #this is how many sides the shape has t.forward(50) #this is the length of each side t.right(90) #this is the angle the turtle turns
20
Create a program to draw a red square using a loop
Activity 11 Create a program to draw a red square using a loop Code Screenshot Shape Screenshot Save the program as turtle11.
21
Create a program to draw a blue equilateral triangle using a loop
Activity 12 Create a program to draw a blue equilateral triangle using a loop Code Screenshot Shape Screenshot Save the program as turtle12.
22
Changes the colour the canvas
Background Colour bgcolor() Changes the colour the canvas t.bgcolor(”red”) Colours include: Red, blue, green, yellow, purple, orange, pink , brown and grey.
23
Save the program as turtle13.
Activity 13 Create a program to draw a green Pentagon using a loop with a background colour of yellow Code Screenshot Shape Screenshot Save the program as turtle13.
24
Save the program as turtle14.
Activity 14 Create a program to draw a yellow Hexagon using a loop with a background colour of black Code Screenshot Shape Screenshot Save the program as turtle14.
25
Save the program as turtle15.
Activity 15 Create a program to draw a purple Heptagon using a loop with a background colour of pink Code Screenshot Shape Screenshot Save the program as turtle15.
26
Save the program as turtle16.
Activity 16 Create a program to draw an orange Octagon using a loop with a background colour of grey Code Screenshot Shape Screenshot Save the program as turtle16.
27
Allows you to colour fill a shape
import turtle as t t.fillcolour(“red”) t.begin_fill() <<< normal shape code goes here >>> t.end_fill()
28
Save the program as turtle17.
Activity 17 Create a program to draw a filled pink Nonagon using a loop with a background colour of green Code Screenshot Shape Screenshot Save the program as turtle17.
29
Save the program as turtle18.
Activity 18 Create a program to draw a filled blue Decagon using a loop with a background colour of yellow Code Screenshot Shape Screenshot Save the program as turtle18.
30
This code creates a Star
Stars This code creates a Star import turtle as t for i in range(50): t.forward(50) t.right(144)
31
Save the program as turtle19.
Activity 19 Create a program to draw a star that uses a size, pen colour, fill colour and background colour of your choice Code Screenshot Shape Screenshot Save the program as turtle19.
32
This code creates a spiralling Star
Stars This code creates a spiralling Star import turtle as t for i in range(50): t.forward(i * 5) t.right(144)
33
Save the program as turtle20.
Activity 20 Create a program to draw a spiralling star that uses a pen colour and background colour of your choice Code Screenshot Shape Screenshot Save the program as turtle20.
34
These commands will help you with the next activities
More Commands These commands will help you with the next activities home() Moves the turtle back to the starting point t.home() penup() Lifts the pen so it does not write when moved t.penup() pendown() Puts the pen down again t.pendown()
35
Write your initials using the Turtle shape
Activity 21 CHALLENGE 1 Write your initials using the Turtle shape You will need to make use of t.penup(), t.pendown() and t.home() AL Code Screenshot Shape Screenshot Save the program as turtle21.
36
Changes the shape of the pen
Pen Shape shape() Changes the shape of the pen t.shape(“turtle”) Choose from: Arrow, turtle, circle, square, triangle, classic.
37
Write a word of your choice
Activity 22 CHALLENGE 2 Write a word of your choice Hello Code Screenshot Shape Screenshot Save the program as turtle22.
38
Save the program as turtle23.
Activity 23 CHALLENGE 3 Draw an image of your choice using the techniques you have learnt today Code Screenshot Shape Screenshot Save the program as turtle23.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.