Practice and reinforce the concepts from Lesson 9
Time Needed: 30-40 minutes
What You'll Create: A colorful pattern of squares using Python's Turtle Graphics! You'll make your turtle draw multiple squares at different positions and sizes, creating beautiful geometric art.
Here's what you need to have ready:
Login to EduBlocks:
Start Your Project:
Configure Your Project:
:bulb: :bulb: Pro Tip: Save your work every 5-10 minutes! Just click the "Save" button so you don't lose your awesome code.
Let's Build Your Pattern Shapes!
Step One: Set Up Your Turtle Graphics :emoji:
First, let's get our turtle ready to draw! Follow these numbered steps:
- Drag the import block:
- Find the
import turtle
block from the Imports section- Drag it to the top of your workspace
- Create your turtle and screen:
- Drag
my_turtle = turtle.Turtle()
from the Turtle section- Drag
my_screen = turtle.Screen()
from the Turtle section- Place these blocks right after your import
- Make your turtle look awesome:
- Drag and connect these blocks in order:
my_turtle.shape("turtle")
- Makes it look like a real turtle!my_turtle.color("white")
- White turtle on purple backgroundmy_turtle.speed(2)
- Not too fast, not too slowmy_turtle.width(3)
- Nice thick lines for our squares- Set up the background:
- Drag
my_screen.bgcolor(149, 125, 173)
- Pretty purple background!- Drag
my_turtle.penup()
- Lift the pen so we don't draw lines yettip :art: Color Tip: The numbers (149, 125, 173) are RGB values that make a nice purple color. In real Python, colors work the same way!
Now we'll create a special function that can draw squares anywhere on the screen!
Start your function:
def my_shape(x, y, length):
x
= horizontal positiony
= vertical positionlength
= how big the square will beInside the function, add these blocks in order:
my_turtle.goto(x, y)
- Moves turtle to starting positionmy_turtle.pendown()
- Put the pen down to start drawingDraw the square (4 sides):
my_turtle.forward(length)
- Draw a linemy_turtle.right(90)
- Turn 90 degreesFinish the function:
my_turtle.penup()
- Lift the pen when done:bulb: :emoji: Why 90 degrees? A square has 4 corners, and each corner is a right angle (90°). So 4 x 90° = 360° - a complete square!
Step 3: Draw Your Square Pattern! :dart:
Time to use your function to create an awesome pattern!
- Call your function 4 times with these exact values:
- Drag
my_shape(0, 0, 120)
- Big square in the center- Drag
my_shape(50, 50, 70)
- Smaller square to the upper right- Drag
my_shape(30, -30, 100)
- Medium square to the lower right- Drag
my_shape(-45, 40, 120)
- Big square to the upper left- What do these numbers mean?
- First number (x): How far left (-) or right (+) from center
- Second number (y): How far down (-) or up (+) from center
- Third number: Size of the square
tip :emoji: Position Tip: The center of the screen is (0, 0). Positive x goes right, negative x goes left. Positive y goes up, negative y goes down!
Having trouble? Here are common issues and fixes:
Problem: "My turtle isn't drawing anything!"
my_turtle.pendown()
before drawingProblem: "My squares look weird!"
Problem: "I can't see my turtle!"
Ready to level up? Try these advanced challenges:
random
module at the toppendown()
, add:
my_turtle.color(random.choice(["red", "blue", "green", "yellow", "orange"]))
Transform your squares into other shapes:
my_turtle.right(72)
instead of 90my_turtle.right(60)
and repeat 6 timesmy_turtle.right(45)
and repeat 8 timesCreate your own unique pattern:
my_shape
8 or more times:bulb: :bulb: Math Connection: The turn angle for any regular polygon = 360° / number of sides. That's why a square uses 90° (360 / 4 = 90)!
Final Checklist :white_check_mark:
Before submitting, make sure your project has:
- Turtle Graphics import at the top
- Turtle and Screen variables created
- All turtle properties set (shape, color, speed, width)
- Purple background color (149, 125, 173)
my_shape
function with x, y, and length parameters- Square drawing with 4 forward/right commands
- All 4 function calls with the correct numbers
- Your code runs without errors!
For the advanced version, also check:
- Random colors OR different shapes
- Your own creative pattern design
Project Submission :emoji:
Great job completing your Pattern Shapes activity! Time to submit your work:
- Test your program - Click the green play button to make sure it works
- Save your project - Click the save button one more time
- Submit your work:
**Submit Your Project Here**tip :memo: Submission Note: You'll need to submit 2 project links:
Make sure both are saved with different names!
Congratulations on creating your Pattern Shapes project! You've learned how to:
Keep experimenting and creating amazing turtle art!