turtle.mode() function in Python
Last Updated :
19 Dec, 2023
Improve
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 'world') and perform reset.
Syntax : turtle.mode(mode=None)
Parameter:
mode: one of the strings 'standard', 'logo' or 'world'
- Mode 'standard' is compatible with turtle.py.
- Mode 'logo' is compatible with most Logo-Turtle-Graphics.
- Mode 'world' uses userdefined 'worldcoordinates'.
Below is the implementation of the above method with some examples :
Example 1 :
# importing package
import turtle
# check by default value
print(turtle.mode())
Output :
standard
Example 2 :
# importing package
import turtle
# motion with default mode (standard)
# default direction of turtle head
# is east in standard mode
turtle.forward(180)
# set mode to 'logo' mode
turtle.mode(mode='logo')
# do some motion
# default direction of turtle head
# is north in logo mode
turtle.forward(120)
# set mode to 'world' mode
turtle.mode(mode='world')
# do some motion
turtle.forward(100)
# set coordinates of the turtle
# mode (world) by choice of user
turtle.setworldcoordinates(-500,-500,500,500)
Output :
