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.getpen()
This function is used to return the Turtleobject itself. It doesn’t require any argument.
Syntax :
turtle.getpen()
Below is the implementation of the above method with some examples :
Example 1 :
Python3
# import package import turtle # get turtle object # and store it turt = turtle.getpen() # print turtle object print (turt) |
Output :
<__main__.Turtle object>
Example 2 :
Python3
# import package import turtle # get turtle object # and store it turt = turtle.getpen() # use it for turtle methods turt.width( 5 ) turt.color( "blue" ) turt.shape( "turtle" ) turt.forward( 150 ) |
Output :