Python - Drawing with Loops

Using loops we can make the code for drawing shapes more efficient.

Watch the video below to see how to use loops when drawing in Python

pythonLoopDraw.mp4

Challenges

See the demonstrations below...

  1. Create a program that can draw a hexagon using the turtle.

The program should ask the user how long the sides of the hexagon should be

You should use a loop to reduce the amount of code that you need to write.

  1. Write a program that will ask the user how many sides the shape should have and how long each side should be.

  2. Write a program that will draw the following shape as efficiently as possibleā€¦

Demo: Challenge 1

Demo: Challenge 2

Demo: Challenge 3

Key Words

Loop

A data structure that allows the code inside it to be repeated.

Turtle Graphics

A way of drawing images on a computer by moving a sprite (turtle) across the screen.