turtle.tilt() function in Python
Last Updated :
26 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.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 turtle
sc = turtle.Screen()
sc.setup( 500 , 300 )
turtle.speed( 1 )
turtle.up()
turtle.setpos( - 200 , 0 )
turtle.down()
turtle.shape( "square" )
turtle.width( 2 )
turtle.forward( 200 )
turtle.tilt( 45 )
turtle.forward( 200 )
|
Output :
Example 2 :
Python3
import turtle
sc = turtle.Screen()
sc.setup( 500 , 350 )
turtle.speed( 1 )
turtle.up()
turtle.setpos( - 50 , 100 )
turtle.down()
turtle.shape( "turtle" )
turtle.width( 2 )
for i in range ( 6 ):
turtle.forward( 100 )
turtle.tilt( 180 )
turtle.stamp()
turtle.right( 60 )
turtle.ht()
|
Output :
Share your thoughts in the comments
Please Login to comment...