Python – turtle.pencolor() method
Last Updated :
29 Jul, 2021
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.pencolor() :
This method is used to change the color of the ink of the turtle drawing. The default color is black.
Syntax: turtle.pencolor(*args)
Arguments: This method have following arguments:
- colorstring: (optional) colorstring A string of color name like “red”, “green”, etc.
- (r, g, b): (optional) A tuple of three values r, g, and b using rgb color code.
- r, g, b: (optional) Three values r, g, and b using rgb color code.
Return: None
Below is the implementation of above method with an example :
Python3
import turtle
turtle.shape( "turtle" )
turtle.colormode( 255 )
turtle.forward( 100 )
turtle.pencolor( "red" )
turtle.right( 90 )
turtle.forward( 100 )
turtle.pencolor(( 41 , 41 , 253 ))
turtle.right( 90 )
turtle.forward( 100 )
turtle.pencolor( 41 , 253 , 41 )
turtle.right( 90 )
turtle.forward( 100 )
|
Output :
Share your thoughts in the comments
Please Login to comment...