Question: I need some help with this project in python, thanks! Regular Polygons with Turtle Graphics in PYTHON Create a Python program that will draw, using

I need some help with this project in python, thanks!

Regular Polygons with Turtle Graphics in PYTHON

Create a Python program that will draw, using Turtle graphics, a regular polygon, one with each side the same length and each angle of the same size, with the number of sides greater than 2 as chosen by the user.

Your code should prompt the user to enter the number of sides he/she would like to see. Use a while loop to allow the user to draw as many polygons as desired. Use the number of sides being less than 3 as the indicator that the user does not want to draw any more polygons. Use a for loop to draw the polygon with side length of (600umber of sides) pixels, that gives us a polygon of circumference of 600 pixels, and a color from the colors list as specified below. The angle, in degrees, to turn right or left may be calculated as 360 divided by the number of sides. For example, the angle for a 12 sided polygon is 360/12 = 30. The angle for a six sided polygon is 60 degrees. The polygons will be drawn with a border color, a fill color, and a border width. Before each new polygon is drawn, the turtle graphic area should be cleared. Set the shape of the turtle to look like a turtle.

The colors list should be defined as follows:

# Specify the colors list to choose the line color and fill color. colors = ['coral', 'gold', 'brown', 'red', 'green', 'blue', 'yellow', 'purple', 'orange', 'cyan', 'pink', 'magenta', 'goldenrod']

To select a color from the colors list, generate a random integer in the range 0-12 and use that as the index into the colors list.

To make sure that the border does not get too fat, we will set its size to be (sides%20) + 1. The modulus operator(%) will give us a value of 0-19, that will give us a width of 1-20.

To draw the polygon, you will write a function with the following header definition:

# The makePolygon function draws a polygon with the number of sides, # side length, border color, border width, and fill color as specified. def makePolygon (sides, length, borderColor, width, fillColor):

where sides is the number of sides of the polygon, length is the length of each side, borderColor is the color of the border of the polygon, width is the width of the border, and fillColor is color the polygon is filled with. This function will be called from the main part of your program to draw the polygons.

Full documentation about all the functions that can be used with turtle can be found at: https://docs.python.org/3.3/library/turtle.html?highlight=turtle (Links to an external site.)Links to an external site. There are several functions to do the same thing in turtle, you may pick any one that works. Your program will need to use turtle functions such as clear(), pencolor(), fillcolor(), shape(), pen_size(), begin_fill(), end_fill(), or ones that do similar things.

I need some help with this project in python, thanks! Regular Polygons

Sample execution Python 3.64 Shell File Edit Shell Debug Options Window Help python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45)Python Tutle Graphics Type "copyright", "credits" or "license )" for more inf RESTART: P:/Cmpsc131/Programming Assignment Solutions/ This program will draw a polygon with 3 or more sides. Enter the number of sides, less than 3 to exit: 7 Enter the number of sides, less than 3 to exit: 19 Enter the number of sides, less than 3 to exit: 20 Enter the number of sides, less than 3 to exit: 18 Enter the number of sides, less than 3 to exit: 18 Enter the number of sides, less than 3 to exit: 100 Enter the number of sides, less than 3 to exit: 100 Enter the number of sides, less than 3 to exit: 100 Enter the number of sides, less than 3 to exit: 120 Enter the number of sides, less than 3 to exit: 119 Enter the number of sides, less than 3 to exit: 4 Enter the number of sides, less than 3 to exit: 4 Enter the number of sides, less than 3 to exit: 6 Enter the number of sides, less than 3 to exit:1 Thanks for using the polygon generator program Your polygon will not necessarily have the same colors since they are randomly selected. Notice the turtle in the drawing, its' back is the color of the fill

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!