Technovation logo

2.5. Practice Makes Perfect




Let’s take another look at drawing a square. How could we re-write it using a loop?


Image of dashed line drawn with Python Turtle
Let’s use what we know about loops to draw a dashed line across the entire box!
The code below draws two dashes. See if you can modify it to use a loop!


Image of a triangle drawn with Python Turtle Image of a pentagon drawn with Python Turtle Image of a hexagon drawn with Python Turtle
Why stop with squares? Shapes with any number of sides can be drawn using a loop!
Start with your code that draws a square. Then, change the number of times the loop repeats and the angle that you turn each time to see if you can draw these shapes.


Image of a row of cirlces drawn with Python Turtle
Try converting you dashed line into a row of circles! Let’s draw 20 circles, each with a radius of 10.


Image of a row of squares drawn with Python Turtle
Try drawing a row of squares!


Image of a plus sign drawn with Python Turtle
Try drawing a plus sign using a loop!
If you’re not sure how to do it with a loop, try writing it out line by line first. Once you’ve got it drawing a plus sign, see if you can put any repeated code in a loop!


Image of an asterisk drawn with Python Turtle
Now try modifying your code from the plus sign into an asterisk!
Hint: you’ll need to change the number of repetitions and the angle that you’re turning each time
You have attempted of activities on this page