turtle.showturtle() function in Python

The turtle.showturtle() function makes the turtle visible on the screen. This is the default state.

Syntax: turtle.showturtle() or turtle.st()
Parameters: None.

Let us see an example to implement the turtle.showturtle() function in Python:

Demo39.py

# turtle.showturtle() function in Python
# Code by Studyopedia

import turtle

window = turtle.Screen()
t = turtle.Turtle()

t.hideturtle()  # Hide the turtle
t.forward(100)
t.showturtle()  # Show the turtle again

window.exitonclick()

The following is the output:

turtle.showturtle() function in Python

In the above code, we followed the below steps:

  • Import module: import turtle loads the turtle graphics library.
  • Create screen: window = turtle.Screen() opens the drawing window.
  • Create turtle: t = turtle.Turtle() creates the turtle you’ll control.
  • Hide turtle: t.hideturtle() hides the turtle cursor (drawing still occurs if the pen is down).
  • Move forward: t.forward(100) moves 100 units, drawing a line if the pen is down (default).
  • Show turtle: t.showturtle() makes the turtle cursor visible again.
  • Close on click: window.exitonclick() waits for a mouse click, then closes the window.

If you liked the tutorial, spread the word and share the link and our website, Studyopedia, with others.


For Videos, Join Our YouTube Channel: Join Now


Read More:

turtle.done() function in Python
turtle.isvisible() function in Python
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment