×
  1. Introduction to Python Turtle Graphics.
  2. Setting up your turtle.
  3. Let's get familiar with turtle.
  4. Now is the for loop.
  5. Let's go to the while loop.
  6. If-else conditional statement.
  7. Multiple turtles at once.
  8. Review section.
  9. Advanced knowlegde about turtle.
Image drawn with Turtle.

Python Turtle Graphics

2. Setting up your turtle !

You will have to complete 1 task in this chapter.

If you want to install Python on your machine, please follow the tutorial below

Introduction

Turtle graphic is the most useful and popular way to introduce programming to kids and help them to engage to the computer field at first sight. This turtle module has been improved from the of the same module from the all the version of Python up until 2.5

Each turtle must have 3 essential properties: a location, an orientation ( or direction), and a pen. A pen can be designed in 3 features: color width and visible or invisible state.

How does turtle work?

A designed turtle will start from assigned position then main make a movement with each specific command, which is easier for beginners to understand and keep track the turtle. They can also predict what the turtle does by imagining themselves as the turtle.

Instruction for downloading python turtle graphic.

Step 1: If you don’t have python programming language, either anaconda or miniconda, please download it in the following website. Please read carefully and choose the most suitable version for your devices: click here to download.

Step 2: : After downloading the suitable programming manager, please now download Python with the latest version, which is Download Python 3.8.5.

Step 3: Now you must install an editor such as visual studio code if you want to write your own code script. You can download Visual Studio code through this link.

Step 4: Now you can create a file and write your own code scrip.

Now, let's set your turtle up !

Please follow the steps below.
  1. You need an import command to run the Python turtle graphic: import turtle. Please type in import turtle at the beginnning of the program. Which had already been imported for you.

  2. In order to set up a turtle, you must create a name for your turtle by using the command: name = turtle.Turtle().
    1. For example, if you would like to call your turtle is “car” then your command should be: car = turtle.Turtle().

  3. Python turtle graphic is just a name of the program and your “turtle” can have various shapes including arrow, circle, square, triangle, classic and also turtle. In order to set up the shape of your turtle you must use the command: name.shape(“the_shape_that you choose”).
    If you skip the command choosing a shape for your turtle then your turtle shape will automatically be an arrow.

  4. If you would like your turtle to have another color that different from black, you must use this command: name.color(“a_color_that_you_prefer”).
    1. For example, if your turtle name is “car” and you would like your turtle to have color of red then your command should be: car.color(“red”).
    If you skip the command choosing a color for your turtle then your turtle color will automatically be black.

  5. You should locate your turtle default position to (0,0) based on the x,y coordinated in algebra. In order to do so, you must use the command: name.goto(0,0)
    1. For example, if your turtle name is “car” and you must set your turtle to the default position, which is (0,0), then your command must be: car.goto(0,0)
The default turtle and import command have been programmed for you. Please based on that and the instruction above to design your own turtle with a different color and shape.

NOW PLEASE TRY IT BY YOURSELF!
# This solution will create a blue turtle with "arrow" shape
sol = turtle.Turtle()
sol.shape("arrow")
sol.color("blue")
from browser import document
import turtle
turtle.set_defaults(
    turtle_canvas_wrapper = document['turtle-div'])

# DO NOT DELETE ABOVE THIS LINE
######## Write your code below

name = turtle.Turtle()
name.shape("turtle")
name.color("red")

# DO NOT DELETE BELOW THIS LINE
turtle.done() 
    


Congratulations! you finish