17 Sep turtle.home() function in Python
The turtle.home() function in Python moves the turtle to the origin coordinates (0, 0) at the center of the screen. Also resets its heading to its standard start position (east, 0 degrees).
Syntax: turtle.home()
Parameters: None.
Let us see an example to implement the turtle.home() function in Python:
Demo8.py
# turtle.home() function in Python # Code by Studyopedia import turtle window = turtle.Screen() t = turtle.Turtle() t.forward(100) t.left(45) t.forward(50) t.home() # Return to origin (0,0) facing east window.exitonclick()
The following is the output:

In the above code, we followed the below steps:
- Import the module: import turtle loads Python’s turtle graphics library for drawing.
- Create the screen: window = turtle.Screen() opens the drawing window.
- Create the turtle: t = turtle.Turtle() makes the turtle (the pen) you’ll control.
- Move forward: t.forward(100) draws a 100-unit line in the current direction.
- Turn left: t.left(45) rotates the turtle 45 degrees counterclockwise without moving.
- Move forward again: t.forward(50) draws a 50-unit line along the new 45° heading.
- Return to origin: t.home() moves the turtle back to the coordinate origin (0, 0) and resets its heading to east; it draws a line on the way if the pen is down (default).
- Close on click: window.exitonclick() keeps the window open until you click inside it, then closes.
If you liked the tutorial, spread the word and share the link and our website, Studyopedia, with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
- OpenCV Tutorial
- Python Tutorial
- NumPy Tutorial
- Pandas Tutorial
- Matplotlib Tutorial
- Generative AI Tutorial
- LangChain Tutorial
- RAG Tutorial
- Machine Learning Tutorial
- Deep Learning Tutorial
- Ollama Tutorial
- Retrieval Augmented Generation (RAG) Tutorial
- Copilot Tutorial
- Gemini Tutorial
- ChatGPT Tutorial
No Comments