turtle.shape() function in Python
Last Updated :
20 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
turtle.shape()
This function is used to set the turtle shape to shape with a given name or, if the name is not given, return the name of the current shape.
Syntax:
turtle.shape(name=None)
Shape with name must exist in the Turtle Screen’s shape dictionary. Initially, there are the following polygon shapes: “arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”. These images are shown below.
default : ‘classic’
‘arrow’
‘turtle’
‘circle’
‘square’
‘triangle’
Example:
Python3
import turtle
turtle.forward( 100 )
turtle.shape( "circle" )
turtle.right( 60 )
turtle.forward( 100 )
turtle.shape( "triangle" )
turtle.right( 60 )
turtle.forward( 100 )
turtle.shape( "square" )
turtle.right( 60 )
turtle.forward( 100 )
turtle.shape( "arrow" )
turtle.right( 60 )
turtle.forward( 100 )
turtle.shape( "turtle" )
turtle.right( 60 )
turtle.forward( 100 )
|
Output:
Share your thoughts in the comments
Please Login to comment...