turtle.turtlesize() function in Python
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
turtle.turtlesize()
This function is used to return or set the pen's attributes x or y-stretchfactors and outline.
Syntax :
turtle.turtlesize(stretch_wid=None, stretch_len=None, outline=None)
Parameters:
Arguments | Value Type | Description |
stretch_wid | positive number | stretchfactor perpendicular to orientation |
stretch_len | positive number | stretchfactor in direction of turtles orientation |
outline | positive number | determines the width of the shapes's outline |
Below is the implementation of the above method with some examples :
Example 1 :
# import package
import turtle
# set turtle
turtle.speed(1)
turtle.shape("turtle")
turtle.fillcolor("blue")
# loop for motion
for i in range(4):
# set turtle width
turtle.turtlesize(stretch_wid=(i+1)*0.5)
turtle.forward(100)
turtle.right(90)
Output :

Example 2 :
# import package
import turtle
# set turtle
turtle.speed(1)
turtle.shape("turtle")
turtle.fillcolor("blue")
# loop for motion
for i in range(4):
# set turtle length
turtle.turtlesize(stretch_len=(i+1)*0.5)
turtle.forward(100)
turtle.right(90)
Output :

Example 3 :
# import package
import turtle
# set turtle
turtle.speed(1)
turtle.shape("turtle")
turtle.fillcolor("blue")
# loop for motion
for i in range(4):
# set turtle outline
turtle.turtlesize(outline=i+1)
turtle.forward(100)
turtle.right(90)
Output :

Example 4 :
# import package
import turtle
# set turtle
turtle.speed(1)
turtle.shape("turtle")
turtle.fillcolor("blue")
# loop for motion
for i in range(4):
# set turtlesize properties all together
turtle.turtlesize(stretch_wid=(i+1)*0.5,
stretch_len=(i+1)*0.5,
outline=(i+1)
)
turtle.forward(100)
turtle.right(90)
Output :
