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 packageimport turtle # check the default valueprint(turtle.color()) |
Output :
('black', 'black')
Example 2 :
Python3
# import packageimport turtle # set the colormode to 255turtle.colormode(255)# set colorturtle.color(0,0,255) # motionfor i in range(20): turtle.forward(2+2*i) turtle.right(90) # set the colormode to 1.0turtle.colormode(1.0) # set colorturtle.color(1.0,0,0) # motionfor i in range(20): turtle.forward(40+4*i) turtle.right(90) |
Output :

