Thursday, July 2, 2026
HomeLanguagesturtle.colormode() function in Python

turtle.colormode() 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.colormode()

This function is used to return the color mode or set it to 1.0 or 255. (r, g, b) values of color triples have to be in range 0 to c mode. It requires only one argument as “cmode”  one of the values 1.0 or 255.

Syntax :

turtle.colormode(mode=None)

Below is the implementation of the above method with some examples :

Example 1 :

Python3




# import package
import turtle
  
# check the default value
print(turtle.color())


Output :

('black', 'black')

Example 2 :

Python3




# import package
import turtle
  
# set the colormode to 255
turtle.colormode(255)
# set color
turtle.color(0,0,255)
  
# motion
for i in range(20):
    turtle.forward(2+2*i)
    turtle.right(90)
  
# set the colormode to 1.0
turtle.colormode(1.0)
  
# set color
turtle.color(1.0,0,0)
  
# motion
for i in range(20):
    turtle.forward(40+4*i)
    turtle.right(90)


Output :

RELATED ARTICLES

5 COMMENTS

Most Popular

Dominic
32519 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6900 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6966 POSTS0 COMMENTS