Blue Hat – Functions & Modules
intermediate30 XP
Turtle Graphics
Draw shapes, patterns, and spirals using the Turtle module
Turtle Graphics
Python
import turtle
t = turtle.Turtle()
t.color("yellow")
# Draw a square
for _ in range(4):
t.forward(100)
t.left(90)Rainbow Spiral
Python
colours = ["red","orange","yellow","green","blue","purple"]
for i in range(100):
t.color(colours[i % len(colours)])
t.forward(i * 2)
t.left(59)⌨️
Type it yourself
Don't just read it — type the example from above into the box, press Run ▶, and watch what happens. Typing it yourself is how it really sticks! Stuck? Tap Show example.
Python · Playground
Output
Press ▶ Run to see your code come to life…Quick check
01/2
What does t.penup() do?