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.heading()
This function is used to return the turtle’s current heading. It doesn’t require any argument.
Syntax :
turtle.heading()
Below is the implementation of the above method with some examples :
Example 1 :
Python3
# import package import turtle
# default heading value print (turtle.heading())
|
Output :
0.0
Example 2 :
Python3
# import package import turtle
# set turtle speed # for better understandings turtle.speed( 1 )
# loop for pattern for i in range ( 4 ):
turtle.forward( 100 )
# get heading value
val = turtle.heading()
# write it
turtle.write( str (val))
turtle.backward( 100 )
turtle.left( 90 )
|
Output :
Article Tags :