Draw Concentric Circles with VIBGYOR Using Turtle in Python

Prerequisite: Turtle Programming Basics

Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc.

To draw Concentric VIBGYOR :

Following steps are used :

  • Importing turtle module
  • Set a screen
  • Make Turtle object
  • Define a method for circle with dynamic radius and colour.
  • Write text by setting turtle object at required position.

Below is the implementation :

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# import turtle package
import turtle
 
# Screen object
sc = turtle.Screen()
 
# Screen background color
sc.bgcolor('black')
 
# turtle object
pen = turtle.Turtle()
 
# turtle width
pen.width(4)
 
 
# function to draw a circle of
# rad radius and col color
def circle(col, rad, val):
   
    pen.color(col)
    pen.circle(rad)
    pen.up()
     
    # set position for space
    pen.setpos(0, val)
    pen.down()
 
 
# function to write text
# by setting positions
def text():
   
    pen.color('white')
    pen.up()
    pen.setpos(-100, 140)
    pen.down()
    pen.write("Concentric VIBGYOR",
              font = ("Verdana", 15))
    pen.up()
    pen.setpos(-82, -188)
    pen.down()
    pen.write("Using Turtle Graphics",
              font = ("Verdana", 12))
    pen.hideturtle()
 
 
# Driver code
 
if __name__ == "__main__" :
   
  # VIBGYOR color list
    col = ['violet', 'indigo', 'blue',
         'green', 'yellow', 'orange',
         'red']
 
  # 7 Concentric circles
  for i in range(7):
     
      # function call
      circle(col[i], -20*(i+1), 20*(i+1))
 
  # function call
  text()

chevron_right


Output :

Concentric Vibgyor




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.