Back

Drawing shapes using functions and the turtle module - practical work 2

Q1. Get this code working:

import turtle
turtle.bgcolor("orange")

def rect(length,width):

     turtle.color("black","red")
     turtle.begin_fill()

     turtle.forward(length)
     turtle.right(90)
     turtle.forward(width)
     turtle.right(90)
     turtle.forward(length)
     turtle.right(90)
     turtle.forward(width)
     turtle.right(90)

turtle.end_fill()

#draw the first rectangle ....
rect(100,50)

Q2. Find the Python 3 turtle documentation by searching for 'Python turtle documentation'
Q3. Find out how to speed up the drawing by using 'speed'.
Q4. Find out how to change the background colour of the turtle drawing window.
Q5. Find out how to change the pensize.
Q6. Explore some of the other instructions you find.
Q7. Find out how to draw a circle.
Q8. Write and call a function that draws a blue hexagon.
Q9. Write and call a function that draws other shapes.
Q10. Email your function to someone else, so they can copy it into their program and use it. If you get organised, a group of you could very quickly produce and share a set of functions to draw lots of different shapes, which you can then use.

Extension task
By writing functions and calling them, draw a geometrical beach scene, with a yellow rectangular beach, a round yellow sun, some mulit-coloured square beach huts, and so on.
 

Back