PYTHON TURTLE
Create a Rainbow Colored Benzene Structure
import turtle #import the turtle library
trt = turtle.Turtle() #initialize the turtle object
scr = turtle.Screen() #initialize the Screen object
scr.bgcolor('black') #set the background color to "black"
scr.title('Color Benzene') #title of the scren
trt.speed(0) #speed of the drawing
rainbow = ['red', 'orange', 'yellow','green', 'blue', 'indigo'] #colors to be used
for i in range(300):
trt.pencolor(rainbow[i%6])
trt.width(i/100 +1)
trt.forward(i)
trt.left(59)
turtle.done()
trt.hideturtle()
Watch the video :
Comments
Post a Comment