turtle.heading() function in Python
Last Updated :
14 Mar, 2022
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 turtle
print (turtle.heading())
|
Output :
0.0
Example 2 :
Python3
import turtle
turtle.speed( 1 )
for i in range ( 4 ):
turtle.forward( 100 )
val = turtle.heading()
turtle.write( str (val))
turtle.backward( 100 )
turtle.left( 90 )
|
Output :
Share your thoughts in the comments
Please Login to comment...