Skip to content
Related Articles

Related Articles

Python – turtle.delay() method
  • Last Updated : 01 Aug, 2020

Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967.

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.delay()

This method is used to return or set the drawing delay in milliseconds. It requires only one optional argument as a positive integer for delay.

Syntax : turtle.delay(delay)
Parameter :

  • delay : a positive integer, denoted the delay time in milliseconds, is optional

Returns : The delayed value



Below is the implementation of above method with some examples :
Example 1 :




# import package
import turtle
  
# turtle movement with
# normal speed
turtle.forward(100)
  
# slow the speed by 
# turtle delay
turtle.delay(50)
  
# turtle movement
turtle.forward(80)

Output :

Example 2 :




# import package
import turtle 
  
# loop for pattern
for i in range(10):
  
    # set turtle delay
    turtle.delay(10 * i)
  
    # motion for pattern
    turtle.forward(50 + 10 * i)
    turtle.right(90)

Output :

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :