Open In App

turtle.heading() function in Python

Last Updated : 14 Mar, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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 :

 

 



Next Article

Similar Reads

turtle.forward() method in Python-Turtle
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.forward() The turtle.forward() method is used to move the turtle forward by the value of the argument that it takes. It gives
1 min read
turtle.setpos() and turtle.goto() functions 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.setpos() This method is used to move the turtle to an absolute position. This method has Aliases: setpos, setposition, goto. S
1 min read
Turtle Race Game Using Python - Turtle Graphics Library
Turtle graphics is a popular way to introduce programming concepts to beginners. It's a fun and interactive module in Python that lets you create simple drawings and animations using a "turtle" that moves around the screen. In this tutorial, we'll create an exciting turtle race game where you can bet on the color of a turtle and watch as they race
4 min read
Working with Titles and Heading - Python docx Module
Prerequisites: docx Word documents contain formatted text wrapped within three object levels. The Lowest level- run objects, middle level- paragraph objects and highest level- document object. So, we cannot work with these documents using normal text editors. But, we can manipulate these word documents in python using the python-docx module. Python
2 min read
Get a list of all the heading tags using BeautifulSoup
In order to print all the heading tags using BeautifulSoup, we use the find_all() method. The find_all method is one of the most common methods in BeautifulSoup. It looks through a tag and retrieves all the occurrences of that tag. Syntax: find_all(name, attrs, recursive, string, limit, **kwargs) An HTML document consists of the following tags - h1
2 min read
turtle.stamp() 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.stamp() This method is used to stamp a copy of the turtleshape onto the canvas and return its id. It doesn't require any argum
1 min read
turtle.Screen().bgcolor() 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.Screen().bgcolor() This method is used to set or return background color of the Turtle Screen. Syntax: turtle.bgcolor(*args) P
1 min read
turtle.distance() 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.distance() This method is used to return the distance from the turtle to (x,y) in turtle step units. Syntax : turtle.distance(
2 min read
turtle.hideturtle() 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.hideturtle() This method is used to make the turtle invisible. It's a good idea to do this while you're in the middle of a com
1 min read
turtle.title() 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.title() This function is used to set the title of turtle-window. It requires only one argument as "titlestring" a string, to a
1 min read
turtle.width() 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.width() This method is used to set or return the line thickness. Set the line thickness to width or return it. If resizemode i
2 min read
turtle.shape() 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.shape() This function is used to set the turtle shape to shape with a given name or, if the name is not given, return the name
1 min read
turtle.write() 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.write() This function is used to write text at the current turtle position. Syntax : turtle.write(arg, move=False, align='left
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 doesn't require any argument and return a boolean
1 min read
turtle.speed() 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.speed() The turtle.speed() method is used to change the speed of the turtle by the value of the argument that it takes. Return
1 min read
turtle.clone() 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.clone() The turtle.clone() method is used to create and return a clone of the turtle with the same position, heading, and turt
2 min read
turtle.isvisible() 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.isvisible() The turtle.isvisible() method is used to return True if the Turtle is shown, False if it's hidden. This method doe
1 min read
turtle.setx() 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.setx() This method is used to set the turtle's first coordinate to x, leave the second coordinate unchanged. Here, whatever th
1 min read
turtle.sety() 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.sety() This method is used to set the turtle's second coordinate to y, leaving the first coordinate unchanged. Here, whatever
1 min read
turtle.seth() 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.seth() This method is used to set the orientation of the turtle to to_angle. This method requires only one argument as an angl
2 min read
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. coordinates (0,0). Whatever, the position of the turtle is,
2 min read
turtle.xcor() 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.xcor() This function is used to return the turtle's x coordinate of the current position of turtle. It doesn't require any arg
1 min read
turtle.ycor() 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.ycor() This function is used to return the turtle's y coordinate of the current position of turtle. It doesn't require any arg
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 turtle is drawing on. It doesn't require any argument
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 require any argument. Syntax : turtle.getpen() Be
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 available turtle shapes. It doesn't require any a
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 a number. The number input must be in the range mi
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 turtle on canvas. Syntax : turtle.ondrag(fun, btn, add)
1 min read
turtle.onclick() 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.onclick() This function is used to bind fun to a mouse-click event on this turtle or on canvas. Syntax : turtle.onclick(fun, b
1 min read
turtle.Screen().turtles() 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.Screen().turtles() This function is used to return the list of turtles on the screen. This doesn't require any argument. Synta
1 min read
Article Tags :
Practice Tags :
  翻译: