import turtle # Create turtle object t = turtle.Turtle() # Loop through each side of the square for i in range(4): # Draw side of square t.forward(50) t.left(90) # Update screen turtle.update() # Keep screen open until user clicks turtle.done()
import turtle # Create turtle object t = turtle.Turtle() # Loop through 36 segments of spiral for i in range(36): # Draw segment of spiral t.circle(10*i) # Update screen turtle.update() # Keep screen open until user clicks turtle.done()In this example, the turtle draws a spiral by looping through 36 segments and calling the `turtle.circle()` method to draw each segment with increasing radius. After each segment is drawn, the Screen update method is called to update the display in real-time. The `turtle.done()` line keeps the window open until the user clicks to close it. Package library: turtle