Turtle Graphics with loops
Shapes
To start, let's try some basic designs without loops.
Square

Rectangle
Let's draw a rectangle using variables. In Python, you name a variable and assign it a value. Replace each length and angle with a variable.
Zigzag
Star

Spiral

Loops
Loops are used when you have a block of code that you want to repeat.
A for loop is used when you have a block of code which you want to repeat a fixed number of times. The for loop iterates through the block of indented code.
for x in range():
x is a variable that steps through values
<do something>
do something in the indented block
Square
Spiral
Polygons
Shape
Sides
Interior Angle
Triangle
3
60
Quadrilateral
4
90
Pentagon
5
108
Hexagon
6
120
Heptagon
7
128.571
Octagon
8
135
Nonagon
9
140
Decagon
10
144
Hendecagon
11
147.273
Dodecagon
12
150
Star
Using a loop, we can produce an eight point star.
What happens if we try changing the range and the left angle?
Spiral Circle
Last updated
Was this helpful?