Open In App

turtle.getpen() function in Python

Last Updated : 23 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
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.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 :


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads