17 Sep turtle.speed() function in Python
The turtle.speed() function in Python sets the turtle’s animation speed. An integer between 0 and 10. 0 is fastest (no animation), 10 is fast, 1 is slowest.
Syntax: turtle.speed(speed=None)
Parameters: speed – an integer in the range 0-10 or a speedstring like “fastest”, “fast”, “normal”, “slow”, “slowest”.
Let us see an example to implement the turtle.speed() function in Python:
Demo9.py
# turtle.speed() function in Python # Code by Studyopedia import turtle window = turtle.Screen() t = turtle.Turtle() t.speed(1) # Slowest speed t.forward(100) t.speed(10) # Fast speed t.left(90) t.forward(100) 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.
- Create the screen: window = turtle.Screen() opens the drawing window.
- Create the turtle: t = turtle.Turtle() makes the turtle (your pen).
- Set slow speed: t.speed(1) sets a very slow animation speed (1 is slowest from 1–10; 0 turns animation off).
- Draw first segment: t.forward(100) moves 100 units forward, drawing slowly.
- Speed up: t.speed(10) switches to fast animation.
- Turn left: t.left(90) rotates the turtle 90° counterclockwise without moving.
- Draw second segment: t.forward(100) draws another 100 units quickly due to the higher speed.
- 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