diff --git a/MakeThePolygon.py b/MakeThePolygon.py new file mode 100644 index 0000000..87b1d9c --- /dev/null +++ b/MakeThePolygon.py @@ -0,0 +1,30 @@ +import turtle + + +#Gets the user's input(sides of the polygon) then calculates the value of the internal angle of the shape +sides_number = int(input("Number of sides:")) +internal_angules = ((sides_number-2)*180)/sides_number + +#Length of the line +proportion = 500/sides_number + +#Opens the window +window = turtle.Screen() + +#Creates the object instance(arrow) for draw and changes it's line width +arrow = turtle.Turtle() +arrow.pensize(3) + +#Draws the regular polygon and fills it +arrow.begin_fill() + +for x in range(sides_number): + arrow.forward(proportion) + arrow.right(180-internal_angules) + +arrow.end_fill() + + +print("Click on the screen to close it") +window.exitonclick() + diff --git a/README.md b/README.md index e052e20..9fd71d1 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Thanks! | temperature_table.py | Prints a table of fahrenheit and Celsius values | [Eventhisone](https://github.com/eventhisone) | [calculatePi.py](https://github.com/accakks/Simple-Programs-in-Python/blob/master/calculatePi.py) | Calculates PI to a specified number of digits of accuracy. | [Joseph-Acevedo](https://github.com/joseph-acevedo) | | [mp3_duration.py](https://github.com/srbilla/Simple-Programs-in-Python/blob/master/mp3_duration.py) | Returns the duration of mp3 file | [Santhosh](https://github.com/srbilla) | +| [MakeThePolygon.py](--) | Construct a regular polygon based on user's input | [IfYouThenTrue](https://github.com/IfYouThenTrue) | [sixers.py](https://github.com/accakks/Simple-Programs-in-Python/blob/master/sixers.py) | Calculates number of days until the next 76ers game this month | [Sabrina Koehler](https://github.com/sabrinakoehler)| |koch_snowflake.py | Draw a Koch snowflake fractal with Turtle module | [Lenart Bucar](https://github.com/LenartBucar) |Quine.py | Quine of python | [Xiao Tan](https://github.com/tvytlx)