I want to draw a filled-in star, such as:
I have this code so far:
def draw_star(size,color):
count = 0
angle = 144
while count <= 5:
turtle.forward(size)
turtle.right(angle)
count += 1
return
draw_star(100,"purple")
I want to fill in the star with whatever color the function is passed. How can I do this?
To get a 5 pointed star, you should draw 2 lines for each side. The angles need to add to 72 (360/5)
import turtle
def draw_star(size, color):
angle = 120
turtle.fillcolor(color)
turtle.begin_fill()
for side in range(5):
turtle.forward(size)
turtle.right(angle)
turtle.forward(size)
turtle.right(72 - angle)
turtle.end_fill()
return
draw_star(100, "purple")
Experiment with different values of angle
to get the shape you want