turtle.distance() function in Python Last Updated : 26 Nov, 2021 Comments Improve Suggest changes Like Article Like Report 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(x, y=None) Parameters: x: x coordinate of Vector 2DVec. y: y coordinate of Vector 2DVec. This method can be called in different formats as given below : distance(x, y) # two coordinates distance((x, y)) # a pair (tuple) of coordinates distance(vec) # e.g. as returned by pos() distance(mypen) # where mypen is another turtle Below is the implementation of the above method with some examples : Example 1 : Python3 # importing package import turtle # print the distance # before any motion print(turtle.distance()) # forward turtle by 100 turtle.forward(100) # print the distance # after a motion print(turtle.distance()) Output : 0.0 100.0 Example 2 : Python3 # importing package import turtle # print distance (default) print(turtle.distance()) for i in range(4): # draw one quadrant turtle.circle(50,90) # print distance print(turtle.distance()) Output : 0.0 70.7106781187 100.0 70.7106781187 1.41063873243e-14 Example 3: Python3 # importing package import turtle # print distance with arguments # in different formats print(turtle.distance(3,4)) print(turtle.distance((3,4))) print(turtle.distance((30.0,40.0))) Output : 5.0 5.0 50.0 Comment More infoAdvertise with us Next Article turtle.distance() function in Python D deepanshu_rustagi Follow Improve Article Tags : Python Python-turtle Practice Tags : python Similar Reads turtle.dot() 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.dot()This function is used to draw a circular dot with a particular size, wi 2 min read turtle.addshape() 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.addshape() This function is used to Adds a turtle shape to TurtleScreen's sh 2 min read turtle.degrees() 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.degrees() This method is used to set angle measurement units to degrees. By 1 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. coordinat 1 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 curr 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 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, leavi 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 curr 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. 2 min read Like