turtle.pen() function in Python Last Updated : 24 Dec, 2021 Comments Improve Suggest changes Like Article Like Report 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.pen() This function is used to return or set the pen's attributes in a 'pen-dictionary' with the following key/value pairs: "shown" : True/False"pendown" : True/False"pencolor" : color-string or color-tuple"fillcolor" : color-string or color-tuple"pensize" : positive number"speed" : number in range 0..10"resizemode" : "auto" or "user" or "noresize""stretchfactor": (positive number, positive number)"shearfactor" : number"outline" : positive number"tilt" : number This dictionary can be used as an argument for a subsequent pen()-call to restore the former pen-state. Moreover, one or more of these attributes can be provided as keyword-arguments. This can be used to set several pen attributes in one statement. Syntax : turtle.pen(pen=None, **pendict) Parameters: pen : a dictionary with some or all of the below listed keys.**pendict : one or more keyword-arguments with the below listed keys as keywords. Below is the implementation of the above method with some examples : Example 1 : Python3 # import package import turtle # check default values print(turtle.pen()) Output : {'shown': True, 'pendown': True, 'pencolor': 'black', 'fillcolor': 'black', 'pensize': 1, 'speed': 3, 'resizemode': 'noresize', 'stretchfactor': (1.0, 1.0), 'shearfactor': 0.0, 'outline': 1, 'tilt': 0.0} Example 2 : Python3 # import package import turtle # check default to compare print(turtle.pen()) # update with some inputs turtle.pen(pencolor="red", outline=2) # again check print(turtle.pen()) Output : {'shown': True, 'pendown': True, 'pencolor': 'black', 'fillcolor': 'black', 'pensize': 1, 'speed': 3, 'resizemode': 'noresize', 'stretchfactor': (1.0, 1.0), 'shearfactor': 0.0, 'outline': 1, 'tilt': 0.0} {'shown': True, 'pendown': True, 'pencolor': 'red', 'fillcolor': 'black', 'pensize': 1, 'speed': 3, 'resizemode': 'noresize', 'stretchfactor': (1.0, 1.0), 'shearfactor': 0.0, 'outline': 2, 'tilt': 0.0} Comment More infoAdvertise with us Next Article turtle.pen() function in Python D deepanshu_rustagi Follow Improve Article Tags : Python Python-turtle Practice Tags : python Similar Reads turtle.mode() 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.mode() This function is used to set turtle-mode ('standard', 'logo' or 'worl 1 min read turtle.onkey() 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.onkey() This function is used to bind fun to the key-release event of the ke 1 min read turtle.ondrag() 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.ondrag() This function is used to bind fun to mouse-move event on this turtl 1 min read turtle.isdown() 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.isdown() This method is used to check whether the turtle is down or not. It 1 min read turtle.onclick() 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.onclick() This function is used to bind fun to a mouse-click event on this t 1 min read turtle.heading() 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.heading() This function is used to return the turtle's current heading. It d 1 min read turtle.dot() 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.dot()This function is used to draw a circular dot with a particular size, wi 2 min read turtle.get_poly() function in Python he 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.get_poly() This function is used to return the lastly recorded polygon. It do 1 min read turtle.numinput() 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.numinput() This function is used to pop up a dialog window for the input of 1 min read Like