turtle.shape() function in Python (original) (raw)

Last Updated : 15 Jul, 2025

The turtle module in Python simplifies graphical programming, making it ideal for beginners. It supports both object-oriented and procedural approaches and relies on Tkinter as its graphical engine. One of its key functions****, turtle.shape(**) allows users to set or retrieve the shape of the turtle cursor. This function can assign predefined or custom shapes and if no shape is specified, it returns the current shape.

**Example:

Python `

import turtle

t = turtle.Turtle()

Set the shape to the default "classic"

t.shape("classic")

Move the turtle forward

t.forward(100)

turtle.done()

`

**Output

Output

Classic Shape

**Explanation: Turtle object is created and its shape is set to "turtle", making it appear like a turtle icon. The turtle then moves forward by 100 units. Finally, **turtle.done() is used to keep the window open, allowing the output to be visible.

**Syntax of turtle.shape()

turtle.shape(name=None)

**Parameters:

Predefined shape

The **turtle module includes a set of built-in shapes that can be used directly:

Shape Name Appearance
"classic" (default) A small arrowhead-like shape
"arrow" An arrow pointing in the turtle's direction
"turtle" A turtle-like shape
"circle" A circular shape
"square" A square shape
"triangle" A triangle shape

These shapes are stored in the **Turtle Screen's shape dictionary, meaning they are predefined and ready for use without requiring additional setup.

turtle-classic

default : 'classic'

turtle-arrow

'arrow'

turtle-Turtle

'turtle'

turtle-circle

'circle'

turtle-square

'square'

turtle-triangle

'triangle'

Examples of turtle.shape()

**Example 1: Using Different Shapes

The following example demonstrates how to set different shapes for the turtle cursor.

Python `

import package

import turtle

for default shape

turtle.forward(100)

for circle shape

turtle.shape("circle") turtle.right(60) turtle.forward(100)

for triangle shape

turtle.shape("triangle") turtle.right(60) turtle.forward(100)

for square shape

turtle.shape("square") turtle.right(60) turtle.forward(100)

for arrow shape

turtle.shape("arrow") turtle.right(60) turtle.forward(100)

for turtle shape

turtle.shape("turtle") turtle.right(60) turtle.forward(100)

`

**Output:

turtle-shape

**Explanation:

Example 2: Animating shape changes

Python `

import turtle import time

Create a turtle object

t = turtle.Turtle()

List of shapes

shapes = ["arrow", "turtle", "circle", "square", "triangle", "classic"]

Move and change shapes dynamically

for shape in shapes: t.shape(shape) t.forward(50) time.sleep(0.5) # Pause for visibility

t.hideturtle() turtle.done()

`

**Output

shape-changes

Shape Changes

**Explanation: