turtle.tilt() function in Python
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.tilt()
This function is used to rotate the turtleshape by the angle from its current tilt-angle, but do NOT change the turtle’s heading (direction of movement).
Syntax :
turtle.tilt(angle)
Below is the implementation of the above method with some examples :
Example 1 :
Python3
# import package import turtle # set turtle screen sc = turtle.Screen() sc.setup( 500 , 300 ) # set turtle turtle.speed( 1 ) turtle.up() turtle.setpos( - 200 , 0 ) turtle.down() turtle.shape( "square" ) turtle.width( 2 ) # motion turtle.forward( 200 ) # tilt turtleshape by 45 turtle.tilt( 45 ) # motion turtle.forward( 200 ) |
Output :
Example 2 :
Python3
# import package import turtle # set screen sc = turtle.Screen() sc.setup( 500 , 350 ) # set turtle turtle.speed( 1 ) turtle.up() turtle.setpos( - 50 , 100 ) turtle.down() turtle.shape( "turtle" ) turtle.width( 2 ) # loop for pattern for i in range ( 6 ): # motion turtle.forward( 100 ) # tilt turtleshpae by 180 turtle.tilt( 180 ) # print turtleshape turtle.stamp() # move to right by 60 turtle.right( 60 ) # hide the turtle turtle.ht() |
Output :
Contact Us