turtle tutorial
import turtlet = turtle.Turtle()t.forward(100) # Move the turtle forward by 100 units
t.left(90) # Turn the turtle left by 90 degreesLast updated
import turtlet = turtle.Turtle()t.forward(100) # Move the turtle forward by 100 units
t.left(90) # Turn the turtle left by 90 degreesLast updated
t.penup() # Lift the pen up, so no drawing occurs
t.pendown() # Put the pen down, so drawing occurs
t.pensize(3) # Set the thickness of the pen to 3 pixels
t.pencolor("blue") # Set the pen color to bluet.speed(speed) # Set the speed of the turtle (0 = fastest, 1 = slowest, 10 = normal)t.forward(distance) # Move the turtle forward
t.backward(distance) # Move the turtle backwardimport turtle
t = turtle.Turtle()
for _ in range(4):
t.forward(100)
t.left(90)
turtle.done() # This keeps the window open after drawing is completeimport turtle
import math
t = turtle.Turtle()
radius = 100
num_sides = 50
angle = 360 / num_sides
for _ in range(num_sides):
t.forward(2 * math.pi * radius / num_sides)
t.left(angle)
turtle.done()t.shape("turtle") # Change the turtle shape to a turtle icon
t.color("green") # Change the color of the turtle
t.speed(1) # Set the speed of the turtle (1 is slowest, 10 is fastest)