Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

turtle.mode() function in Python

  • Last Updated : 06 Aug, 2020

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 :

Python3




# importing package
import turtle
  
# check by default value
print(turtle.mode())

Output :

standard

Example 2 :

Python3




# importing package
import turtle
  
# motion with default mode (standard)
# default direction of turtle head 
# is north in standard mode
turtle.forward(180)
  
# set mode to 'logo' mode
turtle.mode(mode='logo')
  
# do some motion
# default direction of turtle head 
# is east 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 :


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!