• 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 / Python turtle write() – Write Text to Turtle Screen

Python turtle write() – Write Text to Turtle Screen

July 18, 2022 Leave a Comment

To write text with the Python turtle module, you can use the turtle write() function.

import turtle 

t = turtle.Turtle()

t.write("Hello")

You can write text with different font colors, font names, font sizes and font types.

import turtle 

t = turtle.Turtle()

t.color("blue")

t.write("Hello", font=("Arial", 12, "normal")

The turtle module in Python allows us to create graphics easily in our Python code.

We can use the turtle module to write text to the turtle canvas with the write() function.

To use write() function, you just need to pass a string which represents the word you will write to the turtle screen.

Below is an example of how you can write with the turtle write() function in Python.

import turtle 

t = turtle.Turtle()

t.write("Hello")

python turtle write

How to Change Font with Turtle write() Function in Python

If you want to change the font of the text used by the write() function, you can use the parameter called font and with this parameter, you can change the font you write with your turtle.

With the turtle module, we can use a number of different fonts. The fonts you can use with the turtle module are all of the many symbolic font names that Tk recognizes.

The list is hundreds of fonts long, but below are a handful of common fonts you can use with turtle.

fonts = ["Helvetica", "Arial", "Times New Roman", "Calibri", "Courier", "Verdana"]

To change the font for your turtle, just pass the font name you want to use.

Below are some examples of how you can use the font parameter to write with different fonts with turtle in Python.

import turtle 

t = turtle.Turtle()
t.color("green")
t.write("Hello", font=("Calibri", 16, "normal"))

python change turtle font name

import turtle 

t = turtle.Turtle()

t.write("Hello", font=("Arial", 12, "normal"))

python turtle font

How to Change Font Color of Turtle write() Function in Python

By default, the font color for your turtle is black.

You can change the color of your turtle using the turtle color() function. You can use any valid Tk color name with turtle module, as well as RGB colors.

Below shows you an example of how you can change the font color when using the turtle module in Python.

import turtle 

t = turtle.Turtle()
t.color("blue")
t.write("Hello", font=("Times New Roman", 24, "bold"))

python turtle font color

Hopefully this article has been useful for you to learn how you can change the fonts for your turtle in Python.

Other Articles You'll Also Like:

  • 1.  Sorting a List of Tuples by Second Element in Python
  • 2.  How to Save and Use Styles from Existing Word File With python-docx
  • 3.  Golden Ratio Constant phi in Python
  • 4.  Check if Number is Larger than N in Python
  • 5.  Python Remove First Element from List
  • 6.  Perform Reverse Dictionary Lookup in Python
  • 7.  pandas round – Round Numbers in Series or DataFrame
  • 8.  Get Month from Datetime in pandas DataFrame
  • 9.  Draw Star in Python Using turtle Module
  • 10.  Python Square Root – Finding Square Roots Using math.sqrt() Function

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