...

Circle Tracing Challenge

In this lesson, students will be introduced to Turtle graphics in Python. Through a provided template, students will trace existing circles by writing code that utilises these functions, allowing them to explore creative way of drawing through programming.
As part of this project you will learn:

The Turtle library

What is Turtle library?

In Python, a library is a reusable chunk of code you can include in your programs and use pre-existing functionality.

Turtle is a graphic library for Python. Using Turtle, we can easily draw in a drawing board.

First, we import the turtle module. Then create a window, next we create a turtle object and using the turtle method we can draw on the drawing board.

Next
Please ensure all required fields are filled in
Step 1: Let's start coding
  • In your logged-in trinket account click on New Trinket -> Python

  • Or Open the blank Python template trinket: Open New.

  • Prev Next
    Please ensure all required fields are filled in
    Step 2: Create a window
  • The first step is to import the Turtle module. Place import statements at the top of your code.
  • Next, define the screen and specify its dimension. Type the code as follows:
  • done() command must be the last statement in a turtle graphics program.
  • Let's add the background colour to the screen. Follow the code below:
  • The hideturtle() command will hide the cursor
  • Prev Next
    Please ensure all required fields are filled in
    Step 3: Let's explore Turtle Functions

    Now, let's explore some essential Turtle functions. We'll start by drawing a circle and filling it with a colour.
    We will use the following commands:

  • speed(number) - set the speed of your drawing from 0 to 10
  • penup() - This command lifts the turtle's writing pen, so it won't leave a trace while moving.
  • pendown() - With this command, we put the turtle's writing pen back down, allowing it to draw on the screen.
  • goto(x,y) - Use this command to navigate the turtle to a specific coordinate on the screen. The (x, y) values represent the horizontal and vertical positions.
  • color("colourName") - This command sets the colour of the turtle's pen or fill to the specified colour name, such as "blue" in our case.
  • begin_fill() and end_fill() - These commands mark the beginning and end of the shape that we want to fill with the selected colour.
  • forward(number) - Use this command to move the turtle forward by a specified number of pixels.
  • right(angle) and left(angle) - These commands allow the turtle to turn right or left by the specified angle.

  • Type the code as follows:

    Prev Next
    Please ensure all required fields are filled in
    Step 4: Draw the rectangle

    To draw the rectangle, follow these steps:

  • Use the goto(x, y) command to position the turtle at the starting position where you want to draw the rectangle.
  • Select a color using the color("colour name") command. Choose any color you like!
  • Draw a line by moving the turtle forward with the forward(number) command. Specify the length of the line by providing a number.
  • To create a right angle turn, use either right(90) or left(90) command. This will rotate the turtle by 90 degrees.
  • Repeat steps 3 and 4 three more times to complete the rectangle.
  • Here's an example code to help you draw the rectangle:

    Prev Next
    Step 5: Circle Tracing Challenge

    You are given a grid with circles and you need to trace and fill them with specified colors

  • Open template trinket: Open Template.

  • Feel free to experiment with different starting positions,and dimensions to trace the circles. Remember to have fun and unleash your creativity!

    Prev Next
    Please ensure all required fields are filled in
    Step 6: The complete code

    Your code should be similar to this:

    Prev Next
    Please ensure all required fields are filled in
    Step 7: Save your work

  • If you don't have a Trinket account, click the down arrow and then click Link. This will give you a link that you can save and come back to later.
  • If you have a Trinket account, you can click Remix to save your own copy of the trinket.
  • Prev Next
    Step 8: Complete and Share

    Submit your final project



    Copy your Trinket Url

  • Click Share->Link
  • Copy the link to share your code
  • Paste link into the field
  • Prev