Python Turtle Speed With Examples

In this tutorial, we will learn How to manage Turtle speed in Python turtle and we will also cover different examples related to Python Turtle speed. And we will cover these topics.

  • Python turtle speed
  • Python turtle speed up
  • Python turtle speed max
  • Python turtle.speed(0)
  • Python turtle pen speed
  • Python turtle draw speed
  • Python turtle default speed
  • Python turtle move speed
  • Python turtle turn speed
  • Python turtle module speed

Python turtle speed

In this section, we will learn how to control the speed of turtle in Python turtle.

Speed is used to change the speed of a turtle by giving the value as an argument. The turtle speed lies between 0-10.

Syntax:

turtle.speed(speed=None)

Code:

In the following code, we imported the turtle package using import turtle and also create a window. Now, we use this window as a drawing board where we draw some shapes with the help of the turtle and also control the speed of the turtle before drawing.

  • turtle.speed(1) is the slowest speed given to the turtle.
  • turtle.forward(120) is used to define the turtle movement.

from turtle import *
import turtle
ws=turtle.Screen()
ws.title("Python guides")


turtle.speed(1)
turtle.shape("turtle")

turtle.forward(120)
ws.exitonclick()

Output:

After running the above code we will get the following output we see a turtle is moving forward and the speed of the turtle is slowest.

Python turtle speed
Python turtle speed Output

Read: Draw colored filled shapes using Python Turtle

Python turtle speed up

In this section, we will learn how to speed up the turtle in python turtle.

The turtle speed lies in the range 0-10 if we want to increase the speed of the turtle then we increase the input values. Sped from 1 to 10 go faster animation of line drawing and also increase the speed of a turtle.

Code:

In the following code, we take the user input which decides how many squares are needed for drawing the shape and the user also chooses the color of the turtle and speedup() turtle as the user want.

import turtle


s=int(input("Choose the number of squares ?"))
col=int(input("What colour would you like? yellow = 1, pink = 2 "))
back=int(input("What turtle colour would you like? yellow = 1, pink = 2 "))
turtle.speed(1)
i=1

x=65

while i < s:
    i=i+1
    x=x*1.05
    print ("minimise this window AS Soon As Possible!!")
    if col==1:
        turtle.pencolor("yellow")
    elif col==2:
        turtle.pencolor("pink")
   
    else:
        turtle.pencolor("black")
    if back==1:
        turtle.fillcolor("yellow")
    elif back==2:
        turtle.fillcolor("pink")
    else:
        turtle.fillcolor("white")
    turtle.forward(x)
    turtle.right(90)
    turtle.forward(x)
    turtle.right(90)
    turtle.forward(x)
    turtle.right(90)
    turtle.forward(x)
    turtle.right(90)
    turtle.up()
    turtle.right(12)
    turtle.down()

Output:

After running the above code, we get the following output in which we see different squares are drawn with speed(1). Now, if we want to increase the speed of the cursor then, speed up and give the big value in the argument.

Python turtle speed up
Python turtle speed up Output

Read: How to Create a Snake game in Python using Turtle

Python turtle speed max

In this section, we will learn how to max the speed of turtle in Python turtle.

As we know turtle.speed() method is used to change the speed. The turtle speed lies in the range of 0-10. 0 is the fastest speed value in which the speed of the turtle is maxed and also max the speed by different methods.

Code:

In the following, we import some packages from turtle import *, import turtle. And create a loop for the pattern and set turtle speed as turtle.speed(15-i) this shows the max speed of the turtle.


from turtle import *
import turtle 
  

for i in range(15):
    
 
  turtle.speed(15-i)
    
  
  turtle.forward(50+15*i)
  turtle.right(90)

Output:

In the following output, we see in starting turtle move with their max speed and create a square loop.

Python turtle speed max
Python turtle speed max Output

Read: Python Turtle Commands (15 useful commands)

Python turtle.speed(0)

In this section, we learn how to work with the speed(0) method in Python turtle.

Turtle.speed() is used to change the speed of a turtle we can change the value of arguments to manage the speed.

Speed(0) is the fastest speed in this turtle turns instantly they do not take a little sec to turn.

Code:

In the following code, we used turtle.speed(0) method and the value 0 in the argument is used as the fastest speed value.

  • turtle.forward(50) is used to move the turtle forward direction and the default color of the turtle is black.
  • turtle.color(“green”) is used to change the color black to green.
from turtle import *

import turtle
 
turtle.speed(0)


turtle.forward(50)
 

turtle.color("green")
 


turtle.right(90)
turtle.forward(50)
turtle.pencolor(("blue"))
turtle.right(90)
turtle.forward(70)
turtle.pencolor("purple")
turtle.right(90)
turtle.forward(90)

Output:

After running the above code, we get the following output in which we see the animation does not take a sec to occur.

Python turtle speed(0)
Python turtle speed(0) Output

Read: How to attach an image in Turtle Python

Python turtle pen speed

In this section, we will how to control the speed of the pen when we draw a shape in a Python turtle.

We can control the pen speed with a turtle.speed() method. We give the value as an argument and change the speed of the pen.

Code:

In the following code we create a screen inside the screen we draw a shape with the help of a pen with normal speed.

  • turtle.speed(6) is used to set pen speed to normal.
  • tur.pensize(3) is used to set the pen size at 3.
import turtle
 
turtle.setup(900, 700)
turtle.speed(6)
tur = turtle.Turtle()
tur.pensize(3) 
tur.forward(300)
tur.left(90)
tur.forward(200)
exit()

Output:

After running the above code, we get the following output in which we see the speed of our pen is normal and the shape is drawing by the pen.

Python turtle pen speed
Python turtle pen speed Output

Read: Python Turtle Colors

Python turtle draw speed

In this section, we will learn how to control the draw speed in Python turtle.

  • We can control or manage the draw speed by turtle.speed() method.
  • Speedstrings are draw by speed values in the following way:
  • Fastest : 0
  • Slowest: 1
  • Slow : 3
  • Normal: 6
  • Fast: 10

Code:

In the following code, we create a window with the background color “light green” where we draw shapes with the help of a pen and measure the draw speed. The width of the pen is “3”.

from turtle import *
import turtle
turtle.setup(900, 600)      
ws = turtle.Screen()        
ws.bgcolor("light green")    
ws.title("Python guides!")    

tur = turtle.Turtle()
tur.color("blue")           
tur.pensize(3)             

tur.forward(300)
tur.left(120)
tur.forward(300)

ws.exitonclick()

Output:

After running the above code, we get the following output in which we see the draw speed of the turtle.

Python turtle draw speed
Python turtle draw speed Output

Python turtle default speed

In this section, we will learn about the default speed of turtle in Python turtle.

The default speed lies in the range of 0-10. If the input value is greater than 10 or smaller than 0.5, the speed is set to 0.

Code:

In the following code, we create a window this window works as a drawing board where we draw shapes with default speed.

  • tur.speed() is used as a default speed.
  • tur.forward(200) is used for giving the movement to the turtle.
import turtle as tur
ws = tur.Screen()
ws.title("Python guides")


tur.speed()
tur.shape("turtle")
  

tur.forward(200)
tur.right(60)
tur.forward(200)
tur.right(90)
tur.forward(200)

Output:

After running the above code we get the following output in which we see the turtle move with their default speed.

Python turtle default speed
Python turtle default speed Output

Also, Check: Python Turtle Art

Python turtle move speed

In this section, we will learn the moving speed of turtle in Python turtle.

Speed is defined as the fast movement of the object or we can say that to go or move very quickly. Turtle move speed is how fast our turtle moves or which speed they can move.

Code:

In the following code, we create a screen with the background color “black”.The turtle moves on the screen they first move with their normal speed in the forward direction then move right.

  • Turtle – It is a pre-installed library used to create shapes and pictures.
  • color()-It is used to set pen color or it is also used for filling the shape.
  • shape()– It set turtle shape to the shape of the given name.
from turtle import *
import turtle
ws = turtle.Screen()
ws.bgcolor("black")
ws.title("Python guides")
tur = turtle.Turtle()
tur.color("red")
tur.shape("turtle")

print(list(range(8, 90, 3)))
tur.up()                    
for size in range(8, 90, 3):    
    tur.stamp()                
    tur.forward(size)          
    tur.right(50)              

ws.exitonclick()

Output:

In the following output, we see a turtle move at its normal speed and a beautiful shape is created.

Python turtle move speed
Python turtle move speed Output

Read: How to draw a shape in python using Turtle

Python turtle turn speed

In this section, we will learn about the turn speed of turtle in Python turtle.

As we know speed is defined as the movement of the object. So, in this section, we will learn about the turn speed in which we see from which speed a turtle can turn.

Code:

In the following code, we create a screen the background of the screen is a “light green” color on-screen turtle is placed and the turtle moves in the forward direction and then taking a turn to the right with their normal speed.

tur.stamp– It leaves an impression on the canvas.

from turtle import *
import turtle
ws = turtle.Screen()
ws.bgcolor("light blue")
ws.title("Python guides")
tur = turtle.Turtle()
tur.color("red")
tur.shape("circle")
    
    
tur.stamp()                
tur.forward(80)          
tur.right(50)              
tur.forward(80)
tur.right(50)
tur.forward(80)


ws.exitonclick()

Output:

After running the above code we get the following output in which we see a turtle move firstly in the forwarding direction and then turn in the right direction.

Python turtle turn speed
Python turtle turn speed Output


Python turtle module speed

In this section, we will learn about turtle module speed in Python turtle.

The module is defined as each independent unit that can be used to construct a complex structure. Module speed controls the practical speed independently.

Code:

In the following code, we create a screen where we can draw shapes and pictures with the module speed.

  • color()It is used to set pen color or it is also used for filling the shape.
  • speed()– It is an integer value from range 0-10.
from turtle import *
import turtle
ws= turtle.Screen()
ws.title("Python guides")
turtle.speed(6)
color('green', 'pink')
begin_fill()
while True:
    forward(200)
    left(150)
    if abs(pos()) < 1:
        break
end_fill()
ws.exitonclick()

Output:

After running the above code we get the following output in which we see a beautiful picture is drawn with module speed.

Python turtle module speed
Python turtle module speed Output

In this tutorial, we discussed Python turtle speed and we have also covered different examples related to its implementation. Here is the list of examples that we have covered.

  • Python turtle speed
  • Python turtle speed up
  • Python turtle speed max
  • Python turtle.speed(0)
  • Python turtle pen speed
  • Python turtle draw speed
  • Python turtle default speed
  • Python turtle move speed
  • Python turtle turn speed
  • Python turtle module speed