โ† Back to Python Course
๐ŸŽฎ Fun with Pythonยท25 minยทIntermediate
๐Ÿข

Turtle Graphics

Draw shapes with code!

Imagine a turtle with a pen. You tell it where to move, and it draws! Learn to create shapes, spirals, and art.

๐Ÿ“–

What we are learning

Turtle graphics is a fun way to draw pictures with code. Imagine a little turtle holding a pen. You tell it to move forward, turn left, turn right โ€” and it draws a line wherever it goes. You can create squares, stars, spirals, and more!

๐Ÿ’ก Think of it like this:

Think of the turtle like a remote-controlled toy car that paints as it drives. You send commands: "go forward 50 steps, turn right 90 degrees, go forward 50 more." The car paints a trail, and you have drawn a square!

๐ŸŒŸ

Why it matters

Turtle graphics teaches you how code creates visual output. It is a stepping stone to understanding graphics, animation, and game development.

Where you see this in real life:

  • โœ“Educational tools for teaching programming visually
  • โœ“Logo design and geometric art
  • โœ“Introduction to computer graphics and animation
๐ŸŽฏ

By the end, you can:

  • 1.Understand the turtle metaphor
  • 2.Use loops to draw regular shapes
  • 3.Create colorful patterns with loops and turns
๐Ÿ”ค

New words

turtleforwardturnpendegrees
๐Ÿ
If you had a robot turtle with a pen, what would you make it draw first?
๐Ÿค“

Fun Fact!

Turtle graphics was created in 1967 as part of the LOGO programming language. It was one of the first ways kids could learn programming by drawing!

๐Ÿข Turtle Graphics

Imagine a turtle holding a pen. You tell it to move forward, turn left, turn right โ€” and it draws a line wherever it goes. You can create squares, stars, spirals, and more! Since we cannot show turtle graphics in the browser, we will use text-based drawing to learn the same concepts.

๐Ÿ“ Drawing a Square

To draw a square, the turtle moves forward and turns 90 degrees, four times. We can simulate this with text!

๐ŸDraw squares with text!
main.py
โ— Output
Click โ–ถ Run to see the output!

โญ Drawing a Star

A star pattern uses the same loop and string multiplication trick!

๐ŸDraw a star!
main.py
โ— Output
Click โ–ถ Run to see the output!

๐ŸŒ€ Drawing a Spiral

A spiral grows wider with each step. We can simulate this with increasing line lengths!

๐ŸDraw a spiral!
main.py
โ— Output
Click โ–ถ Run to see the output!

๐ŸŒˆ Colorful Patterns

Mix different characters to create colorful-looking patterns!

๐ŸCheckerboard and diamond!
main.py
โ— Output
Click โ–ถ Run to see the output!
๐Ÿ
In real Python (not in the browser), you can use the turtle module to draw with an actual turtle on screen! Try it on your computer with: import turtle
๐Ÿง 

Quick Quiz!

+10 XP

In turtle graphics, what does turning 90 degrees do?

๐Ÿ
Finished the lesson? Click the button to mark it complete and earn XP!