0% found this document useful (0 votes)
7 views6 pages

Turtley Awesome Python Word

The document provides an overview of the Turtle Python library, which is used for creating graphics and shapes on a virtual canvas. It explains how to move the turtle, draw shapes, change pen properties, and manage the drawing process using various commands. Additionally, it includes coding exercises for drawing shapes like squares, rectangles, and circles, as well as manipulating the turtle's attributes.

Uploaded by

sarvvyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Turtley Awesome Python Word

The document provides an overview of the Turtle Python library, which is used for creating graphics and shapes on a virtual canvas. It explains how to move the turtle, draw shapes, change pen properties, and manage the drawing process using various commands. Additionally, it includes coding exercises for drawing shapes like squares, rectangles, and circles, as well as manipulating the turtle's attributes.

Uploaded by

sarvvyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Turtley Awesome

Turtle is a pre-installed Python library that allows us to create


pictures and shapes on a virtual canvas. The onscreen pen that we
use for drawing is called the turtle and this is what gives the library
its name.
Whenever we intend to
access the turtle library, we
MUST include an import
statement. We MUST also
create a variable (t) that
will act as our turtle/pen
Moving the turtle
The turtle can move in 4 directions:
Forward Backward Left Right
We use .forward() or .backward() to move the turtle in the direction
that it is currently facing. We can change the direction the turtle is
facing by turning it .right() or .left() a certain number of degrees.
1. The following code will draw a right angle. The code firstly tells the
turtle to move forward 100 units, then turn right 90 degrees, and
finally move forward another 100 units. Complete the code so that
the turtle draws a square.

2. Now write some code to make the turtle draw a rectangle.


We can also draw a line to any other position on the screen by using
coordinates. The default position of our turtle is coordinates (0,0),
these coordinates are also known as .home(). To draw a line, we use
.goto(), giving the x and y coordinate of the desired location.
3. The following code will draw a line that extends to coordinates
(-120, 180). Complete the code so that the turtle moves to the
opposite side of the screen and then returns to its default position
(This should result in a triangle).
t.goto(-120, 180)

The turtle has pre-set shapes that it can


draw. For a circle, we do not need to write out several lines of code
like we did for a rectangle. Instead, we use .circle() or we can use
.dot() which is a filled in circle. All we need to provide is the radius to
specify the circle size.
4. Write some code that makes the turtle do the following
● Move from the default position
● Draw a circle
● Move to another position
● Draw a dot
● Return to the default position
You may have noticed that the turtle has a default colour and shape
of a black arrow, however we can change this if we wish. The
following are some properties that we can change:
.pensize() Changes the thickness of the pen
.pencolor() Changes the outline colour of the pen
.fillcolor() Changes the fill colour of the pen
.color() Changes both the fill colour and the outline
colour of the pen
.speed() Changes how fast the pen moves
.shape() Changes the shape of the pen
Some shapes we can use:
● Square
● Arrow
● Circle
● Turtle
● Triangle
5. Write the code that does the following:
● Sets the pens outline colour to red
● Sets the pens fill colour to pink
● Sets the pens size to 10
● Sets the pens shape to turtle
● Sets the pens speed to 5
● Draws a circle with a radius of 120
● Reduces the pen size to single digits
● Changes the pens outline colour
● Changes the pens fill colour
● Draws a circle with a radius between 40 & 80

The turtle can also add colour to the shapes we draw. To do this we
use .begin_fill() at the start of our code block and .end_fill() at the
end of our code block. The following incomplete code is supposed to:
● Move the turtle to a new position
● Draw a circle
● Move the turtle to another position
● Draw a square with a red fill
● Return to the default position
6. Complete the code below:
t.goto(-120, 120)
t.circle(80)
You would have noticed that when we use .goto() to move the turtle,
it draws a line as it moves. Sometimes we may want to move the
turtle to a different location without a line being drawn. To do this,
we use .penup() which means the pen has been lifted. We can then
use .pendown() when we want to draw again.
7. Now let us put everything we have learnt into practice. Write the
code that does the following:
● Sets the pens outline colour to blue
● Sets the pens fill colour to pink
● Move the turtle forward 100 units
● Move the turtle up 70 units
● Lift the pen and move to coordinates (-20, -200)
● Draw a square with a pink fill
● Lift the pen and move to coordinates (0, 200)
● Draw a dot
● Return to default position
Your code should produce
something similar to this!

You might also like