Spider Web Challenge

For this challenge our aim was to use Python Turtle to draw a spider web on the screen.

Our code will first will the screen in black (Colour code #000000) and create a Python Turtle called spider, with a light grey colour (Colour code #EEEEEE).


#Spider Web Challenge - 101Computing.net/spider-web-challenge
import turtle

window = turtle.Screen()
window.bgcolor("#000000")
spider = turtle.Turtle()
spider.color("#EEEEEE")
spider.speed(0)
spider.pensize(1)

The second part of our code is to draw the 8 main straight threads in a * shape:

for threads in range(8):
   spider.forward(180)
   spider.back(180)
   spider.left(45)

This is what our spider web looks like so far:

To complete our spider web, we now need to draw arc shapes between these main threads. To do so we will use the following function called drawArc() used to draw an arc shape.

def drawArc(radius,startingAngle,angle):
   spider.setheading(startingAngle+90)
   spider.circle(radius,angle) 

Our function called drawArc() that takes three parameters:

  • The radius of the arc (in pixels)
  • The starting angle of the arc (in degrees)
  • The angle of the arc (in degrees)

To fully understand the purpose of these three parameters let’s look at the following three examples:

The third examples demonstrate how we can use a negative angle to change the direction of the arc. A positive angle draws an arc anti-clockwise, whereas a negative angle draws and arc clockwise.

We will then have to use an iterative approach to draw all the arcs to make up the spider web.

Here is our full code for this spider web challenge:

Did you like this challenge?

Click on a star to rate it!

Average rating 3 / 5. Vote count: 8

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!