top of page

TURTLE LIBRARY

Python provides numerous modules that provide extremely powerful functionality that we can utilize in our own applications. These modules can send emails or grab web pages, for example. One of them is Turtle Module, which enables users to create pictures and shapes by providing them with a virtual canvas. Turtle's Module is meant to teach young people about coding. Python can be utilized in an engaging, playful manner to introduce beginners to programming with the help of Turtle's Module. 

For installing Turtle Module:

>>> pip install PythonTurtle

For importing Turtle Module:

>>>import turtle

Turtle Basics-

For making basic window to see turtle on it-

>>> turtle.Title("Your Title")

  

Turtle Functions-

Students command an interactive Python shell (similar to the IDLE development environment) and the turtle can be manoeuvred using functions such as: turtle.forward and turtle.right.

Turtles use the following methods:

  • Turtle- A new turtle is created and returned by this method

      >>> T=turtle.Turtle()​

  • penup()- The turtle’s Pen is picked up

      >>> p.penup()​

  • pendown()- The turtle’s Pen is put down

      >>> p.pendown()​

  • right()- Rotates the turtle clockwise

      >>> p.right(85)

  • left()- Rotates the turtle anti-clockwise

      >>> p.left(50)​

  • forward()- The turtle is moved forward

      >>> p.forward(45)

  • backward()- The turtle is moved backward

      >>> tur.backward(100)​

  • pencolor()- The turtle’s pen is colored differently

      >>> p.pencolor(“blue”)​

In addition to designing complex shapes, interesting pictures, and various games, we can also create mini games and animations. Turtle library has a bunch of capabilities such as:

   1. Triangle:

   

 

2. Circle:

 

 3. Rectangle:

   4. Square:

For further information, please read the official document of Turtle Module. Click Here!

bottom of page