• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / Changing Python Turtle Size with turtlesize() Function

Changing Python Turtle Size with turtlesize() Function

February 23, 2022 Leave a Comment

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)

turtle size

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)

turtle length size

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)

turtle width size

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)

turtle pen size

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.

Other Articles You'll Also Like:

  • 1.  Length of Set Python – Get Set Length with Python len() Function
  • 2.  How to Write Python Dictionary to File
  • 3.  Apply Function to All Elements in List in Python
  • 4.  Using Python to Count Items in List Matching Criteria
  • 5.  Perfect Numbers in Python
  • 6.  Check if Character is Letter in Python
  • 7.  Get Substring from String in Python with String Slicing
  • 8.  Using Python to Check if Deque is Empty
  • 9.  How to Iterate through a Set Using Python
  • 10.  Sort by Two Keys in Python

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy