Colors and Pen Control Jump to this section
This lesson shows how to change pen and background colors, change the pen size, and fill shapes.
Pen color and size Jump to this section
Use pencolor(...) to set the pen (line) color and pensize(...) to change line thickness.
import turtle
t = turtle.Turtle()
t.pencolor('blue')
t.pensize(4)
t.forward(80)
You can use color names ('red', 'green') or hex strings ('#ff8800').
Pen speed Jump to this section
You can control how fast the turtle draws with speed(value). Values go from 1 to 10, with 1 being the slowest and 10 the fastest. You can also set speed to 0, which skips animations to make the turtle jump between points (and finish drawings the fastest).
import turtle
t = turtle.Turtle()
t.speed(0) # fastest drawing
t.forward(120)
t.left(90)
t.forward(120)
Pen control Jump to this section
To move the turtle without drawing, use penup() (stop drawing) and pendown() (resume drawing). This is useful for repositioning.
import turtle
t = turtle.Turtle()
t.penup()
t.forward(100) # moves without drawing
t.pendown()
t.circle(30) # draws at new position
Try changing the speed value and using penup()/pendown() to build cleaner drawings.
Fill shapes Jump to this section
To draw a filled shape, use begin_fill() and end_fill() and set a fillcolor(...).
import turtle
t = turtle.Turtle()
t.pencolor('black')
t.fillcolor('green')
t.begin_fill()
t.forward(120)
t.left(120)
t.forward(120)
t.left(120)
t.forward(120)
t.left(120)
t.end_fill()
This draws a filled triangle. The outline color comes from pencolor, the interior from fillcolor.
Note: loops are a way to remove the repetitiveness of this code; we'll cover loops in the next lesson.
Background color Jump to this section
You can change the canvas background with screen = turtle.Screen() and screen.bgcolor(...).
import turtle
screen = turtle.Screen()
screen.bgcolor('lightblue')
t = turtle.Turtle()
t.forward(60)
Quick exercises Jump to this section
- Draw a thick red square with a light gray background.
- Draw two concentric filled circles using different fill colors.
