Draw Colorful Spiral Web Using Turtle Graphics in Python

Prerequisite: Turtle Basics

“Turtle” is a Python feature like a drawing board, which lets us command a turtle to draw all over it. This comes packed with the standard Python package and need not be installed externally.

Methods used:

  • forward(value): moves the turtle in the forward direction.
  • turtle.Pen(): setup the turtle pen
  • speed(value): changes the speed of the turtle
  • width(value): set the width
  • left(value): moves the turtle left.
  • bgcolor(color_name): changes background-color

Approach:

  • Import turtle.
  • Define colors using the list data structure in python.
  • Setup a turtle pen for drawing the Spiral Web.
  • Start making the Spiral Web according to your logic. 
     

Below is the implementation of the above approach.



Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# import turtle
import turtle
 
# defining colors
colors = ['red', 'yellow', 'green', 'purple', 'blue', 'orange']
 
# setup turtle pen
t= turtle.Pen()
 
# changes the speed of the turtle
t.speed(10)
 
# changes the background color
turtle.bgcolor("black")
 
# make spiral_web
for x in range(200):
    t.pencolor(colors[x%6]) # setting color
    t.width(x/100 + 1) # setting width
    t.forward(x) # moving forward
    t.left(59) # moving left
 
turtle.done()
t.speed(10)
 
turtle.bgcolor("black") # changes the background color
 
# make spiral_web
for x in range(200):
    t.pencolor(colors[x%6]) # setting color
    t.width(x/100 + 1) # setting width
    t.forward(x) # moving forward
    t.left(59) # moving left
 
turtle.done()

chevron_right


 
 

Output:

 

 

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : pulkitagarwal03pulkit

Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.