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 :
<!–
–>
Please Login to comment…