turtle.heading() function in Python (original) (raw)
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 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 :
Similar Reads
- turtle.home() 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.home() This function is used to move the turtle to the origin i.e. coordinat 1 min read
- turtle.getpen() 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.getpen() This function is used to return the Turtleobject itself. It doesn't 1 min read
- turtle.isdown() 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.isdown() This method is used to check whether the turtle is down or not. It 1 min read
- turtle.numinput() 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.numinput() This function is used to pop up a dialog window for the input of 1 min read
- turtle.onkey() 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.onkey() This function is used to bind fun to the key-release event of the ke 1 min read
- turtle.mode() 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.mode() This function is used to set turtle-mode ('standard', 'logo' or 'worl 1 min read
- turtle.ondrag() 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.ondrag() This function is used to bind fun to mouse-move event on this turtl 1 min read
- turtle.window_height() 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.window_height() This function is used to return the height of the turtle win 1 min read
- turtle.getshapes() 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.getshapes() This function is used to return a list of names of all currently 1 min read
- turtle.getscreen() 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.getscreen() This function is used to Return the TurtleScreen object, the tur 1 min read