21 Sep turtle.resetscreen() function in Python
The turtle.resetscreen() function resets all turtles on the screen to their initial state and clears the drawing. It also resets the background.
Syntax: turtle.resetscreen()
Parameters: None.
Let us see an example to implement the turtle.resetscreen() function in Python:
Demo50.py
# turtle.resetscreen() function in Python # Code by Studyopedia import turtle window = turtle.Screen() t1 = turtle.Turtle() t2 = turtle.Turtle() t1.forward(100) t2.backward(100) turtle.resetscreen() # Reset all turtles and clear screen window.exitonclick()
The following is the output:

In the above code, we followed the below steps:
- Import module: import turtle loads the turtle graphics library.
- Create screen: window = turtle.Screen() opens the drawing window.
- Create turtles: t1 = turtle.Turtle() and t2 = turtle.Turtle() create two independent turtles.
- Move t1 forward: t1.forward(100) draws a 100-unit line in its current heading (default east).
- Move t2 backward: t2.backward(100) moves 100 units opposite its heading (default west).
- Reset screen: turtle.resetscreen() clears the entire canvas, removes all turtle drawings, and reinitializes the screen and turtles to defaults (all turtles reset to start state).
- Close on click: window.exitonclick() waits for a mouse click, then closes the window.
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