6. Write a program that asks the user for the number of sides, the length of the side, the color,
and the fill of a regular polygon. The program should use a turtle to draw the polygon and then
fill it in.

Respuesta :

import turtle

s = turtle.Screen()

t = turtle.Turtle()

sides = int(input("Enter the number of sides: "))

length = int(input("Enter the length of the side: "))

col = input("Enter the color of your polygon: ")

t.fillcolor(col)

t.begin_fill()

for x in range(sides):

   t.forward(length)

   t.right(360/sides)

t.end_fill()

s.mainloop()

I hope this helps!

The program to draw and fill the polygon is an illustration of a graphics program in Python

The program in Python

The program written in Python, where comments are used to explain each line is as follows:

#This imports the turtle module

import turtle

#This defines the screen of the graphics window

scr = turtle.Screen()

#This provides the primitives needed in the program

prim = turtle.Turtle()

#This gets the number of sides

numSides = int(input("Sides: "))

#This gets the length of each sides

sideLength = int(input("Side length: "))

#This gets the fill color

fillColor = input("Fill color: ")

#This sets the fill color

prim.fillcolor(col)

#This begins fill

prim.begin_fill()

#The following iteration draws the polygon

for x in range(numSides):

   prim.forward(length)

   prim.right(360/numSides)

#This ends fill

prim.end_fill()

Read more about Python programs at:

https://brainly.com/question/24833629

#SPJ2

ACCESS MORE