Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

turtle.home() function in Python

  • Last Updated : 21 Jul, 2020

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, it sets to (0,0) with default direction (facing to east).

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Syntax :



turtle.home()

Below is the implementation of the above method with some examples :

Example 1 :

Python3




# import package
import turtle
  
  
# check turtle position
print(turtle.position())
  
# motion
turtle.forward(100)
  
# check turtle position
print(turtle.position())
  
# set turtle to home
turtle.home()
  
# check turtle position
print(turtle.position())
  
# motion
turtle.right(90)
turtle.forward(100)
  
# check turtle position
print(turtle.position())
  
# set turtle to home
turtle.home()
  
# check turtle position
print(turtle.position())

Output :

(0.0, 0.0)
(100.0, 0.0)
(0.0, 0.0)
(0.0, -100.0)
(0.0, 0.0)

Example 2 :

Python3




# import package
import turtle
  
  
# set turtle speed to fastest
# for bettrt understandings
turtle.speed(10)
  
# method to draw a part
def fxn():
    
  # motion
  turtle.circle(50,180)
  turtle.right(90)
  turtle.circle(50,180)
  
# loop to draw pattern
for i in range(12):
  fxn()
    
  # set turtle at home
  turtle.up()
  turtle.home()
  turtle.down()
    
  # set position
  turtle.left(30*(i+1))

Output :




My Personal Notes arrow_drop_up
Recommended Articles
Page :