When using the turtle module in Python, we can change the turtle size with the turtlesize() function to get a bigger or smaller turtle.
import turtle
t = turtle.Turtle()
t.turtlesize(5)
If you’d instead like to change the pen size, you can use the pensize() function.
import turtle
t = turtle.Turtle()
t.pensize(3)
The turtle module in Python allows us to create graphics easily in our Python code.
We can use the turtle module to make all sorts of graphics in Python.
When working with the turtle module, sometimes it makes sense to want to change the size of our turtle.
We can easily change the size of the turtle in Python with the turtesize() function, and pass an integer value to the function which will a multiplier on the default size of the turtle.
If the integer is greater than 1, then the turtle will get bigger.
If you pass a value less than 1, the turtle will get smaller.
Below is an example how to change the size of the turtle to be 100 pixels (5 times the default 20 pixels).
import turtle
t = turtle.Turtle()
t.turtlesize(5)
t.forward(100)
You can change the turtle width and the turtle length with the arguments “stretch_wid” and “stretch_len”.
Below is an example in Python of how to make a turtle longer but not wider with the “stretch_len” argument.
import turtle
t = turtle.Turtle()
t.turtlesize(stretch_len=5)
t.forward(100)
Below is an example in Python of how to make a turtle wider but not longer with the “stretch_wid” argument.
import turtle
t = turtle.Turtle()
t.turtlesize(stretch_wid=5)
t.forward(100)
What is the Default turtle Turtle Size in Python?
When working with the turtle module, we might want to change the turtle size back to the default.
The default turtle size is 20 pixels.
If you’d like to go back to the default turtle size, you can call the turtlesize() function and pass ‘1’.
Below is an example in Python of how to change the turtle size back to the default.
import turtle
t = turtle.Turtle()
t.turtlesize(1)
How to Change the Size of the turtle Pen Color using Python
We can also change the pen size when using the turtle module. The pensize() function controls the thickness of the pen in our drawing.
Below is an example of how to change the size of the turtle pen and then draw a triangle in Python.
import turtle
t = turtle.Turtle()
t.pensize(3)
def draw_triangle(side_length):
for i in range(0,3):
t.forward(side_length)
t.right(120)
draw_triangle(100)
How to Change Size of turtle Screen in Python
If you are looking to change the size of the turtle screen, you can use the screensize() function.
We can easily change the size of the turtle screen in Python with the screensize() function, and pass integer values to the arguments ‘canvwidth’ and ‘canvheight’.
Below is an example how to change the size of the turtle window to have a width of 550 pixels and a height of 350 pixels in Python.
import turtle
turtle.screensize(canvwidth=550, canvheight=350)
Hopefully this article has been useful for you to change the Python turtle size.