In: Computer Science
Write a Python program that draw simple lollipop (a line and few circles, the line should attach to the circle, just as regular lollipop, you decide the colors),
import turtle
lollipop=turtle.Turtle() #creating turtle object
lollipop.penup()
flag=0
#below for loop to draw circle (lollipop)
#the initial radius of the circle will be 120 which will keep on decreasing by 12 after each iteration, there will be total 10 iterations.
for i in range(120, 1, -12):
lollipop.right(90) # Face South
lollipop.forward(i) # Move one radius
lollipop.right(270) # Back to start heading
lollipop.pendown() # Put the pen back down
# choosing two random colors
if(flag==0):
lollipop.fillcolor('green')
flag=1
else:
lollipop.fillcolor('red')
flag=0
lollipop.begin_fill()
lollipop.circle(i)
lollipop.end_fill()
lollipop.penup() # Pen up while we go home
lollipop.home()
#below code of snippet for lollipop stick
lollipop.right(90)
lollipop.forward(120)
lollipop.pendown()
lollipop.pensize("12")
lollipop.pencolor('black')
lollipop.forward(250)